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")]
17 pub struct EncodingProfile(Object<ffi::GstEncodingProfile, ffi::GstEncodingProfileClass>);
18
19 match fn {
20 type_ => || ffi::gst_encoding_profile_get_type(),
21 }
22}
23
24impl EncodingProfile {
25 pub const NONE: Option<&'static EncodingProfile> = None;
26
27 #[doc(alias = "gst_encoding_profile_find")]
28 pub fn find(
29 targetname: &str,
30 profilename: Option<&str>,
31 category: Option<&str>,
32 ) -> Option<EncodingProfile> {
33 assert_initialized_main_thread!();
34 unsafe {
35 from_glib_full(ffi::gst_encoding_profile_find(
36 targetname.to_glib_none().0,
37 profilename.to_glib_none().0,
38 category.to_glib_none().0,
39 ))
40 }
41 }
42
43 #[doc(alias = "gst_encoding_profile_from_discoverer")]
44 pub fn from_discoverer(info: &DiscovererInfo) -> Result<EncodingProfile, glib::BoolError> {
45 skip_assert_initialized!();
46 unsafe {
47 Option::<_>::from_glib_full(ffi::gst_encoding_profile_from_discoverer(
48 info.to_glib_none().0,
49 ))
50 .ok_or_else(|| {
51 glib::bool_error!("Failed to create EncodingProfile from DiscovererInfo")
52 })
53 }
54 }
55
56 #[cfg(feature = "v1_26")]
57 #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
58 #[doc(alias = "gst_encoding_profile_from_string")]
59 pub fn from_string(string: &str) -> Result<EncodingProfile, glib::BoolError> {
60 assert_initialized_main_thread!();
61 unsafe {
62 Option::<_>::from_glib_full(ffi::gst_encoding_profile_from_string(
63 string.to_glib_none().0,
64 ))
65 .ok_or_else(|| glib::bool_error!("Failed to create EncodingProfile from string"))
66 }
67 }
68}
69
70#[cfg(feature = "v1_26")]
71#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
72impl std::fmt::Display for EncodingProfile {
73 #[inline]
74 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
75 f.write_str(&EncodingProfileExt::to_str(self))
76 }
77}
78
79unsafe impl Send for EncodingProfile {}
80unsafe impl Sync for EncodingProfile {}
81
82pub trait EncodingProfileExt: IsA<EncodingProfile> + 'static {
83 #[doc(alias = "gst_encoding_profile_copy")]
84 #[must_use]
85 fn copy(&self) -> EncodingProfile {
86 unsafe {
87 from_glib_full(ffi::gst_encoding_profile_copy(
88 self.as_ref().to_glib_none().0,
89 ))
90 }
91 }
92
93 #[doc(alias = "gst_encoding_profile_get_allow_dynamic_output")]
94 #[doc(alias = "get_allow_dynamic_output")]
95 fn allows_dynamic_output(&self) -> bool {
96 unsafe {
97 from_glib(ffi::gst_encoding_profile_get_allow_dynamic_output(
98 self.as_ref().to_glib_none().0,
99 ))
100 }
101 }
102
103 #[doc(alias = "gst_encoding_profile_get_description")]
104 #[doc(alias = "get_description")]
105 fn description(&self) -> Option<glib::GString> {
106 unsafe {
107 from_glib_none(ffi::gst_encoding_profile_get_description(
108 self.as_ref().to_glib_none().0,
109 ))
110 }
111 }
112
113 #[doc(alias = "gst_encoding_profile_get_file_extension")]
114 #[doc(alias = "get_file_extension")]
115 fn file_extension(&self) -> Option<glib::GString> {
116 unsafe {
117 from_glib_none(ffi::gst_encoding_profile_get_file_extension(
118 self.as_ref().to_glib_none().0,
119 ))
120 }
121 }
122
123 #[doc(alias = "gst_encoding_profile_get_format")]
124 #[doc(alias = "get_format")]
125 fn format(&self) -> gst::Caps {
126 unsafe {
127 from_glib_full(ffi::gst_encoding_profile_get_format(
128 self.as_ref().to_glib_none().0,
129 ))
130 }
131 }
132
133 #[doc(alias = "gst_encoding_profile_get_input_caps")]
134 #[doc(alias = "get_input_caps")]
135 fn input_caps(&self) -> gst::Caps {
136 unsafe {
137 from_glib_full(ffi::gst_encoding_profile_get_input_caps(
138 self.as_ref().to_glib_none().0,
139 ))
140 }
141 }
142
143 #[doc(alias = "gst_encoding_profile_get_name")]
144 #[doc(alias = "get_name")]
145 fn name(&self) -> Option<glib::GString> {
146 unsafe {
147 from_glib_none(ffi::gst_encoding_profile_get_name(
148 self.as_ref().to_glib_none().0,
149 ))
150 }
151 }
152
153 #[doc(alias = "gst_encoding_profile_get_presence")]
154 #[doc(alias = "get_presence")]
155 fn presence(&self) -> u32 {
156 unsafe { ffi::gst_encoding_profile_get_presence(self.as_ref().to_glib_none().0) }
157 }
158
159 #[doc(alias = "gst_encoding_profile_get_preset")]
160 #[doc(alias = "get_preset")]
161 fn preset(&self) -> Option<glib::GString> {
162 unsafe {
163 from_glib_none(ffi::gst_encoding_profile_get_preset(
164 self.as_ref().to_glib_none().0,
165 ))
166 }
167 }
168
169 #[doc(alias = "gst_encoding_profile_get_preset_name")]
170 #[doc(alias = "get_preset_name")]
171 fn preset_name(&self) -> Option<glib::GString> {
172 unsafe {
173 from_glib_none(ffi::gst_encoding_profile_get_preset_name(
174 self.as_ref().to_glib_none().0,
175 ))
176 }
177 }
178
179 #[cfg(feature = "v1_18")]
180 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
181 #[doc(alias = "gst_encoding_profile_get_single_segment")]
182 #[doc(alias = "get_single_segment")]
183 fn is_single_segment(&self) -> bool {
184 unsafe {
185 from_glib(ffi::gst_encoding_profile_get_single_segment(
186 self.as_ref().to_glib_none().0,
187 ))
188 }
189 }
190
191 #[doc(alias = "gst_encoding_profile_get_type_nick")]
192 #[doc(alias = "get_type_nick")]
193 fn type_nick(&self) -> glib::GString {
194 unsafe {
195 from_glib_none(ffi::gst_encoding_profile_get_type_nick(
196 self.as_ref().to_glib_none().0,
197 ))
198 }
199 }
200
201 #[doc(alias = "gst_encoding_profile_is_enabled")]
202 fn is_enabled(&self) -> bool {
203 unsafe {
204 from_glib(ffi::gst_encoding_profile_is_enabled(
205 self.as_ref().to_glib_none().0,
206 ))
207 }
208 }
209
210 #[doc(alias = "gst_encoding_profile_is_equal")]
211 fn is_equal(&self, b: &impl IsA<EncodingProfile>) -> bool {
212 unsafe {
213 from_glib(ffi::gst_encoding_profile_is_equal(
214 self.as_ref().to_glib_none().0,
215 b.as_ref().to_glib_none().0,
216 ))
217 }
218 }
219
220 #[cfg(feature = "v1_26")]
221 #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
222 #[doc(alias = "gst_encoding_profile_to_string")]
223 #[doc(alias = "to_string")]
224 fn to_str(&self) -> glib::GString {
225 unsafe {
226 from_glib_full(ffi::gst_encoding_profile_to_string(
227 self.as_ref().to_glib_none().0,
228 ))
229 }
230 }
231
232 #[cfg(feature = "v1_20")]
233 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
234 #[doc(alias = "element-properties")]
235 fn connect_element_properties_notify<F: Fn(&Self) + Send + Sync + 'static>(
236 &self,
237 f: F,
238 ) -> SignalHandlerId {
239 unsafe extern "C" fn notify_element_properties_trampoline<
240 P: IsA<EncodingProfile>,
241 F: Fn(&P) + Send + Sync + 'static,
242 >(
243 this: *mut ffi::GstEncodingProfile,
244 _param_spec: glib::ffi::gpointer,
245 f: glib::ffi::gpointer,
246 ) {
247 let f: &F = &*(f as *const F);
248 f(EncodingProfile::from_glib_borrow(this).unsafe_cast_ref())
249 }
250 unsafe {
251 let f: Box_<F> = Box_::new(f);
252 connect_raw(
253 self.as_ptr() as *mut _,
254 c"notify::element-properties".as_ptr() as *const _,
255 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
256 notify_element_properties_trampoline::<Self, F> as *const (),
257 )),
258 Box_::into_raw(f),
259 )
260 }
261 }
262}
263
264impl<O: IsA<EncodingProfile>> EncodingProfileExt for O {}