gstreamer/auto/
functions.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::{Bin, ClockTime, DebugGraphDetails, DebugLevel, Element, StackTraceFlags, ffi};
7use glib::{prelude::*, translate::*};
8#[cfg(feature = "v1_28")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
10use std::boxed::Box as Box_;
11
12#[cfg(feature = "v1_28")]
13#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
14#[doc(alias = "gst_call_async")]
15pub fn call_async<P: FnOnce() + Send + Sync + 'static>(func: P) {
16    assert_initialized_main_thread!();
17    let func_data: Box_<P> = Box_::new(func);
18    unsafe extern "C" fn func_func<P: FnOnce() + Send + Sync + 'static>(
19        user_data: glib::ffi::gpointer,
20    ) {
21        unsafe {
22            let callback = Box_::from_raw(user_data as *mut P);
23            (*callback)()
24        }
25    }
26    let func = Some(func_func::<P> as _);
27    let super_callback0: Box_<P> = func_data;
28    unsafe {
29        ffi::gst_call_async(func, Box_::into_raw(super_callback0) as *mut _);
30    }
31}
32
33#[cfg(feature = "v1_28")]
34#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
35#[doc(alias = "gst_check_version")]
36pub fn check_version(major: u32, minor: u32, micro: u32) -> bool {
37    assert_initialized_main_thread!();
38    unsafe { from_glib(ffi::gst_check_version(major, minor, micro)) }
39}
40
41#[cfg(feature = "v1_28")]
42#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
43#[doc(alias = "gst_cpuid_supports_arm_neon")]
44pub fn cpuid_supports_arm_neon() -> bool {
45    assert_initialized_main_thread!();
46    unsafe { from_glib(ffi::gst_cpuid_supports_arm_neon()) }
47}
48
49#[cfg(feature = "v1_28")]
50#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
51#[doc(alias = "gst_cpuid_supports_arm_neon64")]
52pub fn cpuid_supports_arm_neon64() -> bool {
53    assert_initialized_main_thread!();
54    unsafe { from_glib(ffi::gst_cpuid_supports_arm_neon64()) }
55}
56
57#[cfg(feature = "v1_28")]
58#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
59#[doc(alias = "gst_cpuid_supports_x86_3dnow")]
60pub fn cpuid_supports_x86_3dnow() -> bool {
61    assert_initialized_main_thread!();
62    unsafe { from_glib(ffi::gst_cpuid_supports_x86_3dnow()) }
63}
64
65#[cfg(feature = "v1_28")]
66#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
67#[doc(alias = "gst_cpuid_supports_x86_avx")]
68pub fn cpuid_supports_x86_avx() -> bool {
69    assert_initialized_main_thread!();
70    unsafe { from_glib(ffi::gst_cpuid_supports_x86_avx()) }
71}
72
73#[cfg(feature = "v1_28")]
74#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
75#[doc(alias = "gst_cpuid_supports_x86_avx2")]
76pub fn cpuid_supports_x86_avx2() -> bool {
77    assert_initialized_main_thread!();
78    unsafe { from_glib(ffi::gst_cpuid_supports_x86_avx2()) }
79}
80
81#[cfg(feature = "v1_28")]
82#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
83#[doc(alias = "gst_cpuid_supports_x86_mmx")]
84pub fn cpuid_supports_x86_mmx() -> bool {
85    assert_initialized_main_thread!();
86    unsafe { from_glib(ffi::gst_cpuid_supports_x86_mmx()) }
87}
88
89#[cfg(feature = "v1_28")]
90#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
91#[doc(alias = "gst_cpuid_supports_x86_mmxext")]
92pub fn cpuid_supports_x86_mmxext() -> bool {
93    assert_initialized_main_thread!();
94    unsafe { from_glib(ffi::gst_cpuid_supports_x86_mmxext()) }
95}
96
97#[cfg(feature = "v1_28")]
98#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
99#[doc(alias = "gst_cpuid_supports_x86_sse2")]
100pub fn cpuid_supports_x86_sse2() -> bool {
101    assert_initialized_main_thread!();
102    unsafe { from_glib(ffi::gst_cpuid_supports_x86_sse2()) }
103}
104
105#[cfg(feature = "v1_28")]
106#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
107#[doc(alias = "gst_cpuid_supports_x86_sse3")]
108pub fn cpuid_supports_x86_sse3() -> bool {
109    assert_initialized_main_thread!();
110    unsafe { from_glib(ffi::gst_cpuid_supports_x86_sse3()) }
111}
112
113#[cfg(feature = "v1_28")]
114#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
115#[doc(alias = "gst_cpuid_supports_x86_sse4_1")]
116pub fn cpuid_supports_x86_sse4_1() -> bool {
117    assert_initialized_main_thread!();
118    unsafe { from_glib(ffi::gst_cpuid_supports_x86_sse4_1()) }
119}
120
121#[cfg(feature = "v1_28")]
122#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
123#[doc(alias = "gst_cpuid_supports_x86_sse4_2")]
124pub fn cpuid_supports_x86_sse4_2() -> bool {
125    assert_initialized_main_thread!();
126    unsafe { from_glib(ffi::gst_cpuid_supports_x86_sse4_2()) }
127}
128
129#[cfg(feature = "v1_28")]
130#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
131#[doc(alias = "gst_cpuid_supports_x86_ssse3")]
132pub fn cpuid_supports_x86_ssse3() -> bool {
133    assert_initialized_main_thread!();
134    unsafe { from_glib(ffi::gst_cpuid_supports_x86_ssse3()) }
135}
136
137#[doc(alias = "gst_debug_add_ring_buffer_logger")]
138pub fn debug_add_ring_buffer_logger(max_size_per_thread: u32, thread_timeout: u32) {
139    skip_assert_initialized!();
140    unsafe {
141        ffi::gst_debug_add_ring_buffer_logger(max_size_per_thread, thread_timeout);
142    }
143}
144
145#[doc(alias = "gst_debug_bin_to_dot_data")]
146pub fn debug_bin_to_dot_data(bin: &impl IsA<Bin>, details: DebugGraphDetails) -> glib::GString {
147    skip_assert_initialized!();
148    unsafe {
149        from_glib_full(ffi::gst_debug_bin_to_dot_data(
150            bin.as_ref().to_glib_none().0,
151            details.into_glib(),
152        ))
153    }
154}
155
156#[doc(alias = "gst_debug_bin_to_dot_file")]
157pub fn debug_bin_to_dot_file(
158    bin: &impl IsA<Bin>,
159    details: DebugGraphDetails,
160    file_name: impl AsRef<std::path::Path>,
161) {
162    skip_assert_initialized!();
163    unsafe {
164        ffi::gst_debug_bin_to_dot_file(
165            bin.as_ref().to_glib_none().0,
166            details.into_glib(),
167            file_name.as_ref().to_glib_none().0,
168        );
169    }
170}
171
172#[doc(alias = "gst_debug_bin_to_dot_file_with_ts")]
173pub fn debug_bin_to_dot_file_with_ts(
174    bin: &impl IsA<Bin>,
175    details: DebugGraphDetails,
176    file_name: impl AsRef<std::path::Path>,
177) {
178    skip_assert_initialized!();
179    unsafe {
180        ffi::gst_debug_bin_to_dot_file_with_ts(
181            bin.as_ref().to_glib_none().0,
182            details.into_glib(),
183            file_name.as_ref().to_glib_none().0,
184        );
185    }
186}
187
188#[doc(alias = "gst_debug_get_default_threshold")]
189pub fn debug_get_default_threshold() -> DebugLevel {
190    skip_assert_initialized!();
191    unsafe { from_glib(ffi::gst_debug_get_default_threshold()) }
192}
193
194#[doc(alias = "gst_debug_get_stack_trace")]
195pub fn debug_get_stack_trace(flags: StackTraceFlags) -> Result<glib::GString, glib::BoolError> {
196    skip_assert_initialized!();
197    unsafe {
198        Option::<_>::from_glib_full(ffi::gst_debug_get_stack_trace(flags.into_glib()))
199            .ok_or_else(|| glib::bool_error!("Failed to get stack trace"))
200    }
201}
202
203#[doc(alias = "gst_debug_is_active")]
204pub fn debug_is_active() -> bool {
205    skip_assert_initialized!();
206    unsafe { from_glib(ffi::gst_debug_is_active()) }
207}
208
209#[doc(alias = "gst_debug_is_colored")]
210pub fn debug_is_colored() -> bool {
211    skip_assert_initialized!();
212    unsafe { from_glib(ffi::gst_debug_is_colored()) }
213}
214
215#[doc(alias = "gst_debug_print_stack_trace")]
216pub fn debug_print_stack_trace() {
217    skip_assert_initialized!();
218    unsafe {
219        ffi::gst_debug_print_stack_trace();
220    }
221}
222
223#[doc(alias = "gst_debug_remove_ring_buffer_logger")]
224pub fn debug_remove_ring_buffer_logger() {
225    skip_assert_initialized!();
226    unsafe {
227        ffi::gst_debug_remove_ring_buffer_logger();
228    }
229}
230
231#[doc(alias = "gst_debug_ring_buffer_logger_get_logs")]
232pub fn debug_ring_buffer_logger_get_logs() -> Vec<glib::GString> {
233    skip_assert_initialized!();
234    unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_debug_ring_buffer_logger_get_logs()) }
235}
236
237#[doc(alias = "gst_debug_set_active")]
238pub fn debug_set_active(active: bool) {
239    skip_assert_initialized!();
240    unsafe {
241        ffi::gst_debug_set_active(active.into_glib());
242    }
243}
244
245#[doc(alias = "gst_debug_set_colored")]
246pub fn debug_set_colored(colored: bool) {
247    skip_assert_initialized!();
248    unsafe {
249        ffi::gst_debug_set_colored(colored.into_glib());
250    }
251}
252
253#[doc(alias = "gst_debug_set_default_threshold")]
254pub fn debug_set_default_threshold(level: DebugLevel) {
255    skip_assert_initialized!();
256    unsafe {
257        ffi::gst_debug_set_default_threshold(level.into_glib());
258    }
259}
260
261#[doc(alias = "gst_debug_set_threshold_for_name")]
262pub fn debug_set_threshold_for_name(name: &str, level: DebugLevel) {
263    skip_assert_initialized!();
264    unsafe {
265        ffi::gst_debug_set_threshold_for_name(name.to_glib_none().0, level.into_glib());
266    }
267}
268
269#[doc(alias = "gst_debug_set_threshold_from_string")]
270pub fn debug_set_threshold_from_string(list: &str, reset: bool) {
271    skip_assert_initialized!();
272    unsafe {
273        ffi::gst_debug_set_threshold_from_string(list.to_glib_none().0, reset.into_glib());
274    }
275}
276
277#[doc(alias = "gst_debug_unset_threshold_for_name")]
278pub fn debug_unset_threshold_for_name(name: &str) {
279    skip_assert_initialized!();
280    unsafe {
281        ffi::gst_debug_unset_threshold_for_name(name.to_glib_none().0);
282    }
283}
284
285#[doc(alias = "gst_get_main_executable_path")]
286#[doc(alias = "get_main_executable_path")]
287pub fn main_executable_path() -> Result<glib::GString, glib::BoolError> {
288    assert_initialized_main_thread!();
289    unsafe {
290        Option::<_>::from_glib_none(ffi::gst_get_main_executable_path())
291            .ok_or_else(|| glib::bool_error!("Failed to get main executable path"))
292    }
293}
294
295#[doc(alias = "gst_parse_bin_from_description")]
296pub fn parse_bin_from_description(
297    bin_description: &str,
298    ghost_unlinked_pads: bool,
299) -> Result<Bin, glib::Error> {
300    assert_initialized_main_thread!();
301    unsafe {
302        let mut error = std::ptr::null_mut();
303        let ret = ffi::gst_parse_bin_from_description(
304            bin_description.to_glib_none().0,
305            ghost_unlinked_pads.into_glib(),
306            &mut error,
307        );
308        if error.is_null() {
309            Ok(from_glib_none(ret))
310        } else {
311            Err(from_glib_full(error))
312        }
313    }
314}
315
316#[doc(alias = "gst_parse_launch")]
317pub fn parse_launch(pipeline_description: &str) -> Result<Element, glib::Error> {
318    assert_initialized_main_thread!();
319    unsafe {
320        let mut error = std::ptr::null_mut();
321        let ret = ffi::gst_parse_launch(pipeline_description.to_glib_none().0, &mut error);
322        if error.is_null() {
323            Ok(from_glib_none(ret))
324        } else {
325            Err(from_glib_full(error))
326        }
327    }
328}
329
330#[doc(alias = "gst_parse_launchv")]
331pub fn parse_launchv(argv: &[&str]) -> Result<Element, glib::Error> {
332    assert_initialized_main_thread!();
333    unsafe {
334        let mut error = std::ptr::null_mut();
335        let ret = ffi::gst_parse_launchv(argv.to_glib_none().0, &mut error);
336        if error.is_null() {
337            Ok(from_glib_none(ret))
338        } else {
339            Err(from_glib_full(error))
340        }
341    }
342}
343
344#[doc(alias = "gst_update_registry")]
345pub fn update_registry() -> Result<(), glib::error::BoolError> {
346    assert_initialized_main_thread!();
347    unsafe {
348        glib::result_from_gboolean!(ffi::gst_update_registry(), "Failed to update the registry")
349    }
350}
351
352#[doc(alias = "gst_util_get_timestamp")]
353pub fn util_get_timestamp() -> ClockTime {
354    skip_assert_initialized!();
355    unsafe { try_from_glib(ffi::gst_util_get_timestamp()).expect("mandatory glib value is None") }
356}
357
358#[doc(alias = "gst_version")]
359pub fn version() -> (u32, u32, u32, u32) {
360    skip_assert_initialized!();
361    unsafe {
362        let mut major = std::mem::MaybeUninit::uninit();
363        let mut minor = std::mem::MaybeUninit::uninit();
364        let mut micro = std::mem::MaybeUninit::uninit();
365        let mut nano = std::mem::MaybeUninit::uninit();
366        ffi::gst_version(
367            major.as_mut_ptr(),
368            minor.as_mut_ptr(),
369            micro.as_mut_ptr(),
370            nano.as_mut_ptr(),
371        );
372        (
373            major.assume_init(),
374            minor.assume_init(),
375            micro.assume_init(),
376            nano.assume_init(),
377        )
378    }
379}
380
381#[doc(alias = "gst_version_string")]
382pub fn version_string() -> glib::GString {
383    skip_assert_initialized!();
384    unsafe { from_glib_full(ffi::gst_version_string()) }
385}