gstreamer_pbutils/auto/
encoding_profile.rs
1use 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
138mod sealed {
139 pub trait Sealed {}
140 impl<T: super::IsA<super::EncodingProfile>> Sealed for T {}
141}
142
143pub 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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 {}