gstreamer_pbutils/auto/
encoding_profile.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, 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    /// The opaque base class object for all encoding profiles. This contains generic
17    /// information like name, description, format and preset.
18    ///
19    /// ## Properties
20    ///
21    ///
22    /// #### `element-properties`
23    ///  A [`gst::Structure`][crate::gst::Structure] defining the properties to be set to the element
24    /// the profile represents.
25    ///
26    /// For example for `av1enc`:
27    ///
28    /// ```text
29    /// element-properties,row-mt=true, end-usage=vbr
30    /// ```
31    ///
32    /// Readable | Writeable
33    ///
34    ///
35    /// #### `restriction-caps`
36    ///  Readable | Writeable
37    ///
38    /// # Implements
39    ///
40    /// [`EncodingProfileExt`][trait@crate::prelude::EncodingProfileExt], [`trait@glib::ObjectExt`]
41    #[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    /// Find the [`EncodingProfile`][crate::EncodingProfile] with the specified name and category.
53    /// ## `targetname`
54    /// The name of the target
55    /// ## `profilename`
56    /// The name of the profile, if [`None`]
57    /// provided, it will default to the encoding profile called `default`.
58    /// ## `category`
59    /// The target category. Can be [`None`]
60    ///
61    /// # Returns
62    ///
63    /// The matching [`EncodingProfile`][crate::EncodingProfile] or [`None`].
64    #[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    /// Creates a [`EncodingProfile`][crate::EncodingProfile] matching the formats from the given
81    /// [`DiscovererInfo`][crate::DiscovererInfo]. Streams other than audio or video (eg,
82    /// subtitles), are currently ignored.
83    /// ## `info`
84    /// The [`DiscovererInfo`][crate::DiscovererInfo] to read from
85    ///
86    /// # Returns
87    ///
88    /// The new [`EncodingProfile`][crate::EncodingProfile] or [`None`].
89    #[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    /// Converts a string in the "encoding profile serialization format" into a
103    /// GstEncodingProfile. Refer to the encoding-profile documentation for details
104    /// on the format.
105    /// ## `string`
106    /// The string to convert into a GstEncodingProfile.
107    ///
108    /// # Returns
109    ///
110    /// A newly created GstEncodingProfile or NULL if the
111    /// input string is not a valid encoding profile serialization format.
112    #[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
138mod sealed {
139    pub trait Sealed {}
140    impl<T: super::IsA<super::EncodingProfile>> Sealed for T {}
141}
142
143/// Trait containing all [`struct@EncodingProfile`] methods.
144///
145/// # Implementors
146///
147/// [`EncodingAudioProfile`][struct@crate::EncodingAudioProfile], [`EncodingContainerProfile`][struct@crate::EncodingContainerProfile], [`EncodingProfile`][struct@crate::EncodingProfile], [`EncodingVideoProfile`][struct@crate::EncodingVideoProfile]
148pub trait EncodingProfileExt: IsA<EncodingProfile> + sealed::Sealed + 'static {
149    #[doc(alias = "gst_encoding_profile_copy")]
150    #[must_use]
151    fn copy(&self) -> EncodingProfile {
152        unsafe {
153            from_glib_full(ffi::gst_encoding_profile_copy(
154                self.as_ref().to_glib_none().0,
155            ))
156        }
157    }
158
159    /// Get whether the format that has been negotiated in at some point can be renegotiated
160    /// later during the encoding.
161    #[doc(alias = "gst_encoding_profile_get_allow_dynamic_output")]
162    #[doc(alias = "get_allow_dynamic_output")]
163    fn allows_dynamic_output(&self) -> bool {
164        unsafe {
165            from_glib(ffi::gst_encoding_profile_get_allow_dynamic_output(
166                self.as_ref().to_glib_none().0,
167            ))
168        }
169    }
170
171    ///
172    /// # Returns
173    ///
174    /// the description of the profile, can be [`None`].
175    #[doc(alias = "gst_encoding_profile_get_description")]
176    #[doc(alias = "get_description")]
177    fn description(&self) -> Option<glib::GString> {
178        unsafe {
179            from_glib_none(ffi::gst_encoding_profile_get_description(
180                self.as_ref().to_glib_none().0,
181            ))
182        }
183    }
184
185    ///
186    /// # Returns
187    ///
188    /// a suitable file extension for `self`, or NULL.
189    #[doc(alias = "gst_encoding_profile_get_file_extension")]
190    #[doc(alias = "get_file_extension")]
191    fn file_extension(&self) -> Option<glib::GString> {
192        unsafe {
193            from_glib_none(ffi::gst_encoding_profile_get_file_extension(
194                self.as_ref().to_glib_none().0,
195            ))
196        }
197    }
198
199    ///
200    /// # Returns
201    ///
202    /// (nullable): the [`gst::Caps`][crate::gst::Caps] corresponding to the media format used
203    /// in the profile. Unref after usage.
204    #[doc(alias = "gst_encoding_profile_get_format")]
205    #[doc(alias = "get_format")]
206    fn format(&self) -> gst::Caps {
207        unsafe {
208            from_glib_full(ffi::gst_encoding_profile_get_format(
209                self.as_ref().to_glib_none().0,
210            ))
211        }
212    }
213
214    /// Computes the full output caps that this `self` will be able to consume.
215    ///
216    /// # Returns
217    ///
218    /// The full caps the given `self` can consume. Call
219    /// `gst_caps_unref()` when you are done with the caps.
220    #[doc(alias = "gst_encoding_profile_get_input_caps")]
221    #[doc(alias = "get_input_caps")]
222    fn input_caps(&self) -> gst::Caps {
223        unsafe {
224            from_glib_full(ffi::gst_encoding_profile_get_input_caps(
225                self.as_ref().to_glib_none().0,
226            ))
227        }
228    }
229
230    ///
231    /// # Returns
232    ///
233    /// the name of the profile, can be [`None`].
234    #[doc(alias = "gst_encoding_profile_get_name")]
235    #[doc(alias = "get_name")]
236    fn name(&self) -> Option<glib::GString> {
237        unsafe {
238            from_glib_none(ffi::gst_encoding_profile_get_name(
239                self.as_ref().to_glib_none().0,
240            ))
241        }
242    }
243
244    ///
245    /// # Returns
246    ///
247    /// The number of times the profile is used in its parent
248    /// container profile. If 0, it is not a mandatory stream.
249    #[doc(alias = "gst_encoding_profile_get_presence")]
250    #[doc(alias = "get_presence")]
251    fn presence(&self) -> u32 {
252        unsafe { ffi::gst_encoding_profile_get_presence(self.as_ref().to_glib_none().0) }
253    }
254
255    ///
256    /// # Returns
257    ///
258    /// the name of the [`gst::Preset`][crate::gst::Preset] to be used in the profile.
259    /// This is the name that has been set when saving the preset.
260    #[doc(alias = "gst_encoding_profile_get_preset")]
261    #[doc(alias = "get_preset")]
262    fn preset(&self) -> Option<glib::GString> {
263        unsafe {
264            from_glib_none(ffi::gst_encoding_profile_get_preset(
265                self.as_ref().to_glib_none().0,
266            ))
267        }
268    }
269
270    ///
271    /// # Returns
272    ///
273    /// the name of the [`gst::Preset`][crate::gst::Preset] factory to be used in the profile.
274    #[doc(alias = "gst_encoding_profile_get_preset_name")]
275    #[doc(alias = "get_preset_name")]
276    fn preset_name(&self) -> Option<glib::GString> {
277        unsafe {
278            from_glib_none(ffi::gst_encoding_profile_get_preset_name(
279                self.as_ref().to_glib_none().0,
280            ))
281        }
282    }
283
284    ///
285    /// # Returns
286    ///
287    /// [`true`] if the stream represented by `self` should use a single
288    /// segment before the encoder, [`false`] otherwise. This means that buffers will be retimestamped
289    /// and segments will be eat so as to appear as one segment.
290    #[cfg(feature = "v1_18")]
291    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
292    #[doc(alias = "gst_encoding_profile_get_single_segment")]
293    #[doc(alias = "get_single_segment")]
294    fn is_single_segment(&self) -> bool {
295        unsafe {
296            from_glib(ffi::gst_encoding_profile_get_single_segment(
297                self.as_ref().to_glib_none().0,
298            ))
299        }
300    }
301
302    ///
303    /// # Returns
304    ///
305    /// the human-readable name of the type of `self`.
306    #[doc(alias = "gst_encoding_profile_get_type_nick")]
307    #[doc(alias = "get_type_nick")]
308    fn type_nick(&self) -> glib::GString {
309        unsafe {
310            from_glib_none(ffi::gst_encoding_profile_get_type_nick(
311                self.as_ref().to_glib_none().0,
312            ))
313        }
314    }
315
316    #[doc(alias = "gst_encoding_profile_is_enabled")]
317    fn is_enabled(&self) -> bool {
318        unsafe {
319            from_glib(ffi::gst_encoding_profile_is_enabled(
320                self.as_ref().to_glib_none().0,
321            ))
322        }
323    }
324
325    #[doc(alias = "gst_encoding_profile_is_equal")]
326    fn is_equal(&self, b: &impl IsA<EncodingProfile>) -> bool {
327        unsafe {
328            from_glib(ffi::gst_encoding_profile_is_equal(
329                self.as_ref().to_glib_none().0,
330                b.as_ref().to_glib_none().0,
331            ))
332        }
333    }
334
335    /// Converts a GstEncodingProfile to a string in the "Encoding Profile
336    /// serialization format".
337    ///
338    /// # Returns
339    ///
340    /// A string representation of the GstEncodingProfile.
341    #[cfg(feature = "v1_26")]
342    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
343    #[doc(alias = "gst_encoding_profile_to_string")]
344    #[doc(alias = "to_string")]
345    fn to_str(&self) -> glib::GString {
346        unsafe {
347            from_glib_full(ffi::gst_encoding_profile_to_string(
348                self.as_ref().to_glib_none().0,
349            ))
350        }
351    }
352
353    #[cfg(feature = "v1_20")]
354    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
355    #[doc(alias = "element-properties")]
356    fn connect_element_properties_notify<F: Fn(&Self) + Send + Sync + 'static>(
357        &self,
358        f: F,
359    ) -> SignalHandlerId {
360        unsafe extern "C" fn notify_element_properties_trampoline<
361            P: IsA<EncodingProfile>,
362            F: Fn(&P) + Send + Sync + 'static,
363        >(
364            this: *mut ffi::GstEncodingProfile,
365            _param_spec: glib::ffi::gpointer,
366            f: glib::ffi::gpointer,
367        ) {
368            let f: &F = &*(f as *const F);
369            f(EncodingProfile::from_glib_borrow(this).unsafe_cast_ref())
370        }
371        unsafe {
372            let f: Box_<F> = Box_::new(f);
373            connect_raw(
374                self.as_ptr() as *mut _,
375                b"notify::element-properties\0".as_ptr() as *const _,
376                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
377                    notify_element_properties_trampoline::<Self, F> as *const (),
378                )),
379                Box_::into_raw(f),
380            )
381        }
382    }
383}
384
385impl<O: IsA<EncodingProfile>> EncodingProfileExt for O {}