Skip to main content

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