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
138/// Trait containing all [`struct@EncodingProfile`] methods.
139///
140/// # Implementors
141///
142/// [`EncodingAudioProfile`][struct@crate::EncodingAudioProfile], [`EncodingContainerProfile`][struct@crate::EncodingContainerProfile], [`EncodingProfile`][struct@crate::EncodingProfile], [`EncodingVideoProfile`][struct@crate::EncodingVideoProfile]
143pub 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    /// Get whether the format that has been negotiated in at some point can be renegotiated
155    /// later during the encoding.
156    #[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    ///
167    /// # Returns
168    ///
169    /// the description of the profile, can be [`None`].
170    #[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    ///
181    /// # Returns
182    ///
183    /// a suitable file extension for `self`, or NULL.
184    #[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    ///
195    /// # Returns
196    ///
197    /// (nullable): the [`gst::Caps`][crate::gst::Caps] corresponding to the media format used
198    /// in the profile. Unref after usage.
199    #[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    /// Computes the full output caps that this `self` will be able to consume.
210    ///
211    /// # Returns
212    ///
213    /// The full caps the given `self` can consume. Call
214    /// `gst_caps_unref()` when you are done with the caps.
215    #[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    ///
226    /// # Returns
227    ///
228    /// the name of the profile, can be [`None`].
229    #[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    ///
240    /// # Returns
241    ///
242    /// The number of times the profile is used in its parent
243    /// container profile. If 0, it is not a mandatory stream.
244    #[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    ///
251    /// # Returns
252    ///
253    /// the name of the [`gst::Preset`][crate::gst::Preset] to be used in the profile.
254    /// This is the name that has been set when saving the preset.
255    #[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    ///
266    /// # Returns
267    ///
268    /// the name of the [`gst::Preset`][crate::gst::Preset] factory to be used in the profile.
269    #[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    ///
280    /// # Returns
281    ///
282    /// [`true`] if the stream represented by `self` should use a single
283    /// segment before the encoder, [`false`] otherwise. This means that buffers will be retimestamped
284    /// and segments will be eat so as to appear as one segment.
285    #[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    ///
298    /// # Returns
299    ///
300    /// the human-readable name of the type of `self`.
301    #[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    /// Converts a GstEncodingProfile to a string in the "Encoding Profile
331    /// serialization format".
332    ///
333    /// # Returns
334    ///
335    /// A string representation of the GstEncodingProfile.
336    #[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 {}