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
6#[cfg(feature = "v1_30")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
8use crate::Structure;
9use crate::{Bin, ClockTime, DebugGraphDetails, DebugLevel, Element, StackTraceFlags, ffi};
10use glib::{prelude::*, translate::*};
11#[cfg(feature = "v1_28")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
13use std::boxed::Box as Box_;
14
15/// Calls `func` from another thread and passes `user_data` to it.
16/// ## `func`
17/// function to call asynchronously from another thread
18#[cfg(feature = "v1_28")]
19#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
20#[doc(alias = "gst_call_async")]
21pub fn call_async<P: FnOnce() + Send + Sync + 'static>(func: P) {
22    assert_initialized_main_thread!();
23    let func_data: Box_<P> = Box_::new(func);
24    unsafe extern "C" fn func_func<P: FnOnce() + Send + Sync + 'static>(
25        user_data: glib::ffi::gpointer,
26    ) {
27        unsafe {
28            let callback = Box_::from_raw(user_data as *mut P);
29            (*callback)()
30        }
31    }
32    let func = Some(func_func::<P> as _);
33    let super_callback0: Box_<P> = func_data;
34    unsafe {
35        ffi::gst_call_async(func, Box_::into_raw(super_callback0) as *mut _);
36    }
37}
38
39/// Applications might want to check if the runtime GStreamer version is greater
40/// or equal to the version specified using `major`, `minor` and `micro`.
41/// ## `major`
42/// Major version number
43/// ## `minor`
44/// Minor version number
45/// ## `micro`
46/// Micro version number
47///
48/// # Returns
49///
50/// [`true`] if the GStreamer version is greater or equal to
51/// `major`\.`minor`\.`micro`, [`false`] otherwise. Also this function returns [`false`]
52/// when checking for a different `major` version to the current one, as major
53/// version bumps are ABI breaks anyway.
54#[cfg(feature = "v1_28")]
55#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
56#[doc(alias = "gst_check_version")]
57pub fn check_version(major: u32, minor: u32, micro: u32) -> bool {
58    assert_initialized_main_thread!();
59    unsafe { from_glib(ffi::gst_check_version(major, minor, micro)) }
60}
61
62///
63/// # Returns
64///
65/// [`true`] if NEON (32-bit) is supported by the CPU, [`false`] otherwise.
66#[cfg(feature = "v1_28")]
67#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
68#[doc(alias = "gst_cpuid_supports_arm_neon")]
69pub fn cpuid_supports_arm_neon() -> bool {
70    assert_initialized_main_thread!();
71    unsafe { from_glib(ffi::gst_cpuid_supports_arm_neon()) }
72}
73
74///
75/// # Returns
76///
77/// [`true`] if NEON (64-bit) is supported by the CPU, [`false`] otherwise.
78#[cfg(feature = "v1_28")]
79#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
80#[doc(alias = "gst_cpuid_supports_arm_neon64")]
81pub fn cpuid_supports_arm_neon64() -> bool {
82    assert_initialized_main_thread!();
83    unsafe { from_glib(ffi::gst_cpuid_supports_arm_neon64()) }
84}
85
86///
87/// # Returns
88///
89/// [`true`] if RISC-V Vector extension is supported by the CPU, [`false`] otherwise.
90#[cfg(feature = "v1_30")]
91#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
92#[doc(alias = "gst_cpuid_supports_riscv_v")]
93pub fn cpuid_supports_riscv_v() -> bool {
94    assert_initialized_main_thread!();
95    unsafe { from_glib(ffi::gst_cpuid_supports_riscv_v()) }
96}
97
98///
99/// # Returns
100///
101/// [`true`] if 3DNow! is supported by the CPU, [`false`] otherwise.
102#[cfg(feature = "v1_28")]
103#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
104#[doc(alias = "gst_cpuid_supports_x86_3dnow")]
105pub fn cpuid_supports_x86_3dnow() -> bool {
106    assert_initialized_main_thread!();
107    unsafe { from_glib(ffi::gst_cpuid_supports_x86_3dnow()) }
108}
109
110///
111/// # Returns
112///
113/// [`true`] if AVX is supported by the CPU, [`false`] otherwise.
114#[cfg(feature = "v1_28")]
115#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
116#[doc(alias = "gst_cpuid_supports_x86_avx")]
117pub fn cpuid_supports_x86_avx() -> bool {
118    assert_initialized_main_thread!();
119    unsafe { from_glib(ffi::gst_cpuid_supports_x86_avx()) }
120}
121
122///
123/// # Returns
124///
125/// [`true`] if avx2 is supported by the CPU, [`false`] otherwise.
126#[cfg(feature = "v1_28")]
127#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
128#[doc(alias = "gst_cpuid_supports_x86_avx2")]
129pub fn cpuid_supports_x86_avx2() -> bool {
130    assert_initialized_main_thread!();
131    unsafe { from_glib(ffi::gst_cpuid_supports_x86_avx2()) }
132}
133
134///
135/// # Returns
136///
137/// [`true`] if MMX is supported by the CPU, [`false`] otherwise.
138#[cfg(feature = "v1_28")]
139#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
140#[doc(alias = "gst_cpuid_supports_x86_mmx")]
141pub fn cpuid_supports_x86_mmx() -> bool {
142    assert_initialized_main_thread!();
143    unsafe { from_glib(ffi::gst_cpuid_supports_x86_mmx()) }
144}
145
146///
147/// # Returns
148///
149/// [`true`] if extended MMX is supported by the CPU, [`false`] otherwise.
150#[cfg(feature = "v1_28")]
151#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
152#[doc(alias = "gst_cpuid_supports_x86_mmxext")]
153pub fn cpuid_supports_x86_mmxext() -> bool {
154    assert_initialized_main_thread!();
155    unsafe { from_glib(ffi::gst_cpuid_supports_x86_mmxext()) }
156}
157
158///
159/// # Returns
160///
161/// [`true`] if SSE2 is supported by the CPU, [`false`] otherwise.
162#[cfg(feature = "v1_28")]
163#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
164#[doc(alias = "gst_cpuid_supports_x86_sse2")]
165pub fn cpuid_supports_x86_sse2() -> bool {
166    assert_initialized_main_thread!();
167    unsafe { from_glib(ffi::gst_cpuid_supports_x86_sse2()) }
168}
169
170///
171/// # Returns
172///
173/// [`true`] if SSE3 is supported by the CPU, [`false`] otherwise.
174#[cfg(feature = "v1_28")]
175#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
176#[doc(alias = "gst_cpuid_supports_x86_sse3")]
177pub fn cpuid_supports_x86_sse3() -> bool {
178    assert_initialized_main_thread!();
179    unsafe { from_glib(ffi::gst_cpuid_supports_x86_sse3()) }
180}
181
182///
183/// # Returns
184///
185/// [`true`] if SSE4.1 is supported by the CPU, [`false`] otherwise.
186#[cfg(feature = "v1_28")]
187#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
188#[doc(alias = "gst_cpuid_supports_x86_sse4_1")]
189pub fn cpuid_supports_x86_sse4_1() -> bool {
190    assert_initialized_main_thread!();
191    unsafe { from_glib(ffi::gst_cpuid_supports_x86_sse4_1()) }
192}
193
194///
195/// # Returns
196///
197/// [`true`] if SSSE3 is supported by the CPU, [`false`] otherwise.
198#[cfg(feature = "v1_28")]
199#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
200#[doc(alias = "gst_cpuid_supports_x86_sse4_2")]
201pub fn cpuid_supports_x86_sse4_2() -> bool {
202    assert_initialized_main_thread!();
203    unsafe { from_glib(ffi::gst_cpuid_supports_x86_sse4_2()) }
204}
205
206///
207/// # Returns
208///
209/// [`true`] if SSSE3 is supported by the CPU, [`false`] otherwise.
210#[cfg(feature = "v1_28")]
211#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
212#[doc(alias = "gst_cpuid_supports_x86_ssse3")]
213pub fn cpuid_supports_x86_ssse3() -> bool {
214    assert_initialized_main_thread!();
215    unsafe { from_glib(ffi::gst_cpuid_supports_x86_ssse3()) }
216}
217
218/// Adds a memory ringbuffer based debug logger that stores up to
219/// `max_size_per_thread` bytes of logs per thread and times out threads after
220/// `thread_timeout` seconds of inactivity.
221///
222/// Logs can be fetched with [`debug_ring_buffer_logger_get_logs()`][crate::debug_ring_buffer_logger_get_logs()] and the
223/// logger can be removed again with [`debug_remove_ring_buffer_logger()`][crate::debug_remove_ring_buffer_logger()].
224/// Only one logger at a time is possible.
225/// ## `max_size_per_thread`
226/// Maximum size of log per thread in bytes
227/// ## `thread_timeout`
228/// Timeout for threads in seconds
229#[doc(alias = "gst_debug_add_ring_buffer_logger")]
230pub fn debug_add_ring_buffer_logger(max_size_per_thread: u32, thread_timeout: u32) {
231    skip_assert_initialized!();
232    unsafe {
233        ffi::gst_debug_add_ring_buffer_logger(max_size_per_thread, thread_timeout);
234    }
235}
236
237/// To aid debugging applications one can use this method to obtain the whole
238/// network of gstreamer elements that form the pipeline into a dot file.
239///
240/// See [`debug_bin_to_dot_file()`][crate::debug_bin_to_dot_file()] for more details.
241/// ## `bin`
242/// the top-level pipeline that should be analyzed
243/// ## `details`
244/// type of [`DebugGraphDetails`][crate::DebugGraphDetails] to use
245///
246/// # Returns
247///
248/// a string containing the pipeline in graphviz
249/// dot format.
250#[doc(alias = "gst_debug_bin_to_dot_data")]
251pub fn debug_bin_to_dot_data(bin: &impl IsA<Bin>, details: DebugGraphDetails) -> glib::GString {
252    skip_assert_initialized!();
253    unsafe {
254        from_glib_full(ffi::gst_debug_bin_to_dot_data(
255            bin.as_ref().to_glib_none().0,
256            details.into_glib(),
257        ))
258    }
259}
260
261/// To aid debugging applications one can use this method to write out the whole
262/// network of gstreamer elements that form the pipeline into a dot file.
263/// This file can be processed with graphviz to get an image, like this:
264///
265/// **⚠️ The following code is in  shell ⚠️**
266///
267/// ``` shell
268/// dot -Tpng -oimage.png graph_lowlevel.dot
269/// ```
270///
271/// There is also the interactive [gst-dots-viewer](https://gstreamer.freedesktop.org/documentation/coretracers/dots.html)
272/// tool, and [xdot](https://pypi.org/project/xdot/) which allows you to view the
273/// dot file directly without converting it first.
274///
275/// If `file_name` is NULL, the output filename will be based on the application
276/// name as returned by `g_get_application_name()`, or "unnamed" if the application
277/// name cannot be determined.
278///
279/// The file will be written to the directory specified by the
280/// `GST_DEBUG_DUMP_DOT_DIR` environment variable, and the `.dot` extension will be
281/// added. If `GST_DEBUG_DUMP_DOT_DIR` was not defined at the time
282/// `gst_init()` was called, the file will not be generated. Note that the
283/// directory must already exist, it will not be created by this function.
284///
285/// [`debug_bin_to_dot_data()`][crate::debug_bin_to_dot_data()] can be used if it is desired to generate the
286/// file even when `GST_DEBUG_DUMP_DOT_DIR` is not set.
287/// ## `bin`
288/// the top-level pipeline that should be analyzed
289/// ## `details`
290/// type of [`DebugGraphDetails`][crate::DebugGraphDetails] to use
291/// ## `file_name`
292/// output base filename (e.g. "myplayer")
293#[doc(alias = "gst_debug_bin_to_dot_file")]
294pub fn debug_bin_to_dot_file(
295    bin: &impl IsA<Bin>,
296    details: DebugGraphDetails,
297    file_name: Option<impl AsRef<std::path::Path>>,
298) {
299    skip_assert_initialized!();
300    unsafe {
301        ffi::gst_debug_bin_to_dot_file(
302            bin.as_ref().to_glib_none().0,
303            details.into_glib(),
304            file_name.as_ref().map(|p| p.as_ref()).to_glib_none().0,
305        );
306    }
307}
308
309/// This works like [`debug_bin_to_dot_file()`][crate::debug_bin_to_dot_file()], but adds the current timestamp
310/// to the filename, so that it can be used to take multiple snapshots.
311/// ## `bin`
312/// the top-level pipeline that should be analyzed
313/// ## `details`
314/// type of [`DebugGraphDetails`][crate::DebugGraphDetails] to use
315/// ## `file_name`
316/// output base filename (e.g. "myplayer")
317#[doc(alias = "gst_debug_bin_to_dot_file_with_ts")]
318pub fn debug_bin_to_dot_file_with_ts(
319    bin: &impl IsA<Bin>,
320    details: DebugGraphDetails,
321    file_name: Option<impl AsRef<std::path::Path>>,
322) {
323    skip_assert_initialized!();
324    unsafe {
325        ffi::gst_debug_bin_to_dot_file_with_ts(
326            bin.as_ref().to_glib_none().0,
327            details.into_glib(),
328            file_name.as_ref().map(|p| p.as_ref()).to_glib_none().0,
329        );
330    }
331}
332
333/// Returns the default threshold that is used for new categories.
334///
335/// # Returns
336///
337/// the default threshold level
338#[doc(alias = "gst_debug_get_default_threshold")]
339pub fn debug_get_default_threshold() -> DebugLevel {
340    skip_assert_initialized!();
341    unsafe { from_glib(ffi::gst_debug_get_default_threshold()) }
342}
343
344/// ## `flags`
345/// A set of [`StackTraceFlags`][crate::StackTraceFlags] to determine how the stack trace should
346/// look like. Pass `GST_STACK_TRACE_SHOW_NONE` to retrieve a minimal backtrace.
347///
348/// # Returns
349///
350/// a stack trace, if libunwind or glibc backtrace are
351/// present, else [`None`].
352#[doc(alias = "gst_debug_get_stack_trace")]
353pub fn debug_get_stack_trace(flags: StackTraceFlags) -> Result<glib::GString, glib::BoolError> {
354    skip_assert_initialized!();
355    unsafe {
356        Option::<_>::from_glib_full(ffi::gst_debug_get_stack_trace(flags.into_glib()))
357            .ok_or_else(|| glib::bool_error!("Failed to get stack trace"))
358    }
359}
360
361/// Checks if debugging output is activated.
362///
363/// # Returns
364///
365/// [`true`], if debugging is activated
366#[doc(alias = "gst_debug_is_active")]
367pub fn debug_is_active() -> bool {
368    skip_assert_initialized!();
369    unsafe { from_glib(ffi::gst_debug_is_active()) }
370}
371
372/// Checks if the debugging output should be colored.
373///
374/// # Returns
375///
376/// [`true`], if the debug output should be colored.
377#[doc(alias = "gst_debug_is_colored")]
378pub fn debug_is_colored() -> bool {
379    skip_assert_initialized!();
380    unsafe { from_glib(ffi::gst_debug_is_colored()) }
381}
382
383/// If libunwind, glibc backtrace or DbgHelp are present
384/// a stack trace is printed.
385#[doc(alias = "gst_debug_print_stack_trace")]
386pub fn debug_print_stack_trace() {
387    skip_assert_initialized!();
388    unsafe {
389        ffi::gst_debug_print_stack_trace();
390    }
391}
392
393/// Removes any previously added ring buffer logger with
394/// [`debug_add_ring_buffer_logger()`][crate::debug_add_ring_buffer_logger()].
395#[doc(alias = "gst_debug_remove_ring_buffer_logger")]
396pub fn debug_remove_ring_buffer_logger() {
397    skip_assert_initialized!();
398    unsafe {
399        ffi::gst_debug_remove_ring_buffer_logger();
400    }
401}
402
403/// Fetches the current logs per thread from the ring buffer logger. See
404/// [`debug_add_ring_buffer_logger()`][crate::debug_add_ring_buffer_logger()] for details.
405///
406/// # Returns
407///
408/// NULL-terminated array of
409/// strings with the debug output per thread
410#[doc(alias = "gst_debug_ring_buffer_logger_get_logs")]
411pub fn debug_ring_buffer_logger_get_logs() -> Vec<glib::GString> {
412    skip_assert_initialized!();
413    unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_debug_ring_buffer_logger_get_logs()) }
414}
415
416/// If activated, debugging messages are sent to the debugging
417/// handlers.
418/// It makes sense to deactivate it for speed issues.
419/// > This function is not threadsafe. It makes sense to only call it
420/// during initialization.
421/// ## `active`
422/// Whether to use debugging output or not
423#[doc(alias = "gst_debug_set_active")]
424pub fn debug_set_active(active: bool) {
425    skip_assert_initialized!();
426    unsafe {
427        ffi::gst_debug_set_active(active.into_glib());
428    }
429}
430
431/// Sets or unsets the use of coloured debugging output.
432/// Same as gst_debug_set_color_mode () with the argument being
433/// being GST_DEBUG_COLOR_MODE_ON or GST_DEBUG_COLOR_MODE_OFF.
434///
435/// This function may be called before `gst_init()`.
436/// ## `colored`
437/// Whether to use colored output or not
438#[doc(alias = "gst_debug_set_colored")]
439pub fn debug_set_colored(colored: bool) {
440    skip_assert_initialized!();
441    unsafe {
442        ffi::gst_debug_set_colored(colored.into_glib());
443    }
444}
445
446/// Sets the default threshold to the given level and updates all categories to
447/// use this threshold.
448///
449/// This function may be called before `gst_init()`.
450/// ## `level`
451/// level to set
452#[doc(alias = "gst_debug_set_default_threshold")]
453pub fn debug_set_default_threshold(level: DebugLevel) {
454    skip_assert_initialized!();
455    unsafe {
456        ffi::gst_debug_set_default_threshold(level.into_glib());
457    }
458}
459
460/// Sets all categories which match the given glob style pattern to the given
461/// level.
462/// ## `name`
463/// name of the categories to set
464/// ## `level`
465/// level to set them to
466#[doc(alias = "gst_debug_set_threshold_for_name")]
467pub fn debug_set_threshold_for_name(name: &str, level: DebugLevel) {
468    skip_assert_initialized!();
469    unsafe {
470        ffi::gst_debug_set_threshold_for_name(name.to_glib_none().0, level.into_glib());
471    }
472}
473
474/// Sets the debug logging wanted in the same form as with the GST_DEBUG
475/// environment variable. You can use wildcards such as `*`, but note that
476/// the order matters when you use wild cards, e.g. `foosrc:6,*src:3,*:2` sets
477/// everything to log level 2.
478/// ## `list`
479/// comma-separated list of "category:level" pairs to be used
480///  as debug logging levels
481/// ## `reset`
482/// [`true`] to clear all previously-set debug levels before setting
483///  new thresholds
484/// [`false`] if adding the threshold described by `list` to the one already set.
485#[doc(alias = "gst_debug_set_threshold_from_string")]
486pub fn debug_set_threshold_from_string(list: &str, reset: bool) {
487    skip_assert_initialized!();
488    unsafe {
489        ffi::gst_debug_set_threshold_from_string(list.to_glib_none().0, reset.into_glib());
490    }
491}
492
493/// Resets all categories with the given name back to the default level.
494/// ## `name`
495/// name of the categories to set
496#[doc(alias = "gst_debug_unset_threshold_for_name")]
497pub fn debug_unset_threshold_for_name(name: &str) {
498    skip_assert_initialized!();
499    unsafe {
500        ffi::gst_debug_unset_threshold_for_name(name.to_glib_none().0);
501    }
502}
503
504/// This helper is mostly helpful for plugins that need to
505/// inspect the folder of the main executable to determine
506/// their set of features.
507///
508/// When a plugin is initialized from the gst-plugin-scanner
509/// external process, the returned path will be the same as from the
510/// parent process.
511///
512/// # Returns
513///
514/// The path of the executable that
515///  initialized GStreamer, or [`None`] if it could not be determined.
516#[doc(alias = "gst_get_main_executable_path")]
517#[doc(alias = "get_main_executable_path")]
518pub fn main_executable_path() -> Result<glib::GString, glib::BoolError> {
519    assert_initialized_main_thread!();
520    unsafe {
521        Option::<_>::from_glib_none(ffi::gst_get_main_executable_path())
522            .ok_or_else(|| glib::bool_error!("Failed to get main executable path"))
523    }
524}
525
526/// This is a convenience wrapper around [`parse_launch()`][crate::parse_launch()] to create a
527/// [`Bin`][crate::Bin] from a gst-launch-style pipeline description. See
528/// [`parse_launch()`][crate::parse_launch()] and the gst-launch man page for details about the
529/// syntax. Ghost pads on the bin for unlinked source or sink pads
530/// within the bin can automatically be created (but only a maximum of
531/// one ghost pad for each direction will be created; if you expect
532/// multiple unlinked source pads or multiple unlinked sink pads
533/// and want them all ghosted, you will have to create the ghost pads
534/// yourself).
535///
536/// A bin inside `bin_description` that has [`BinFlags::NO_AUTO_GHOSTPADS`][crate::BinFlags::NO_AUTO_GHOSTPADS]
537/// set is linked through its own pads, and the pads of its children are
538/// never ghosted on the returned bin.
539/// ## `bin_description`
540/// command line describing the bin
541/// ## `ghost_unlinked_pads`
542/// whether to automatically create ghost pads
543///  for unlinked source or sink pads within the bin
544///
545/// # Returns
546///
547/// a
548///  newly-created bin, or [`None`] if an error occurred.
549#[doc(alias = "gst_parse_bin_from_description")]
550pub fn parse_bin_from_description(
551    bin_description: &str,
552    ghost_unlinked_pads: bool,
553) -> Result<Bin, glib::Error> {
554    assert_initialized_main_thread!();
555    unsafe {
556        let mut error = std::ptr::null_mut();
557        let ret = ffi::gst_parse_bin_from_description(
558            bin_description.to_glib_none().0,
559            ghost_unlinked_pads.into_glib(),
560            &mut error,
561        );
562        if error.is_null() {
563            Ok(from_glib_none(ret))
564        } else {
565            Err(from_glib_full(error))
566        }
567    }
568}
569
570/// Create a new pipeline based on command line syntax.
571/// Please note that you might get a return value that is not [`None`] even though
572/// the `error` is set. In this case there was a recoverable parsing error and you
573/// can try to play the pipeline.
574///
575/// To create a sub-pipeline (bin) for embedding into an existing pipeline
576/// use [`parse_bin_from_description()`][crate::parse_bin_from_description()].
577/// ## `pipeline_description`
578/// the command line describing the pipeline
579///
580/// # Returns
581///
582/// a new element on success, [`None`] on
583///  failure. If more than one toplevel element is specified by the
584///  `pipeline_description`, all elements are put into a [`Pipeline`][crate::Pipeline], which
585///  than is returned.
586#[doc(alias = "gst_parse_launch")]
587pub fn parse_launch(pipeline_description: &str) -> Result<Element, glib::Error> {
588    assert_initialized_main_thread!();
589    unsafe {
590        let mut error = std::ptr::null_mut();
591        let ret = ffi::gst_parse_launch(pipeline_description.to_glib_none().0, &mut error);
592        if error.is_null() {
593            Ok(from_glib_none(ret))
594        } else {
595            Err(from_glib_full(error))
596        }
597    }
598}
599
600/// Create a new element based on command line syntax.
601/// `error` will contain an error message if an erroneous pipeline is specified.
602/// An error does not mean that the pipeline could not be constructed.
603/// ## `argv`
604/// null-terminated array of arguments
605///
606/// # Returns
607///
608/// a new element on success and [`None`]
609/// on failure.
610#[doc(alias = "gst_parse_launchv")]
611pub fn parse_launchv(argv: &[&str]) -> Result<Element, glib::Error> {
612    assert_initialized_main_thread!();
613    unsafe {
614        let mut error = std::ptr::null_mut();
615        let ret = ffi::gst_parse_launchv(argv.to_glib_none().0, &mut error);
616        if error.is_null() {
617            Ok(from_glib_none(ret))
618        } else {
619            Err(from_glib_full(error))
620        }
621    }
622}
623
624/// Unpacks an `untrusted-content` report into its parts, so a caller does not
625/// have to know the field names and nesting the structure uses. Each output is
626/// filled with the corresponding part when it is present, and set to [`None`] when
627/// it is not; pass [`None`] for the parts you do not care about.
628/// ## `report`
629/// an `untrusted-content` [`Structure`][crate::Structure], as returned by
630///  [`ParseContext::untrusted_report()`][crate::ParseContext::untrusted_report()]
631///
632/// # Returns
633///
634/// [`true`] if `report` is an `untrusted-content` report.
635///
636/// ## `elements`
637///
638///  the factory names refused because they are not untrusted-aware, or [`None`]
639///
640/// ## `properties`
641/// the refused sensitive
642///  property assignments, a [`Structure`][crate::Structure] named
643///  `untrusted-sensitive-properties` with one `element-name:property` field
644///  per assignment holding the refused value (in the property's own type
645///  when known, the string as written otherwise), or [`None`]
646///
647/// ## `unresolved_properties`
648/// the refused
649///  assignments to children that never materialized, a [`Structure`][crate::Structure] named
650///  `untrusted-unresolved-properties` of the same shape but with the value
651///  always the string as written, since the type is not known, or [`None`]
652#[cfg(feature = "v1_30")]
653#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
654#[doc(alias = "gst_parse_untrusted_report")]
655pub fn parse_untrusted_report(
656    report: &Structure,
657) -> Option<(Vec<glib::GString>, Option<Structure>, Option<Structure>)> {
658    assert_initialized_main_thread!();
659    unsafe {
660        let mut elements = std::ptr::null_mut();
661        let mut properties = std::ptr::null_mut();
662        let mut unresolved_properties = std::ptr::null_mut();
663        let ret = from_glib(ffi::gst_parse_untrusted_report(
664            report.to_glib_none().0,
665            &mut elements,
666            &mut properties,
667            &mut unresolved_properties,
668        ));
669        if ret {
670            Some((
671                FromGlibPtrContainer::from_glib_full(elements),
672                from_glib_full(properties),
673                from_glib_full(unresolved_properties),
674            ))
675        } else {
676            None
677        }
678    }
679}
680
681//#[cfg(feature = "v1_30")]
682//#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
683//#[doc(alias = "gst_trace_event")]
684//pub fn trace_event(format: /*Ignored*/&mut TraceFormat, values: /*Ignored*/&[&TraceValue]) {
685//    unsafe { TODO: call ffi:gst_trace_event() }
686//}
687
688//#[cfg(feature = "v1_30")]
689//#[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
690//#[doc(alias = "gst_trace_span_begin")]
691//pub fn trace_span_begin(format: /*Ignored*/&mut TraceFormat, values: /*Ignored*/&[&TraceValue]) -> TraceSpanId {
692//    unsafe { TODO: call ffi:gst_trace_span_begin() }
693//}
694
695/// Forces GStreamer to re-scan its plugin paths and update the default
696/// plugin registry.
697///
698/// Applications will almost never need to call this function, it is only
699/// useful if the application knows new plugins have been installed (or old
700/// ones removed) since the start of the application (or, to be precise, the
701/// first call to `gst_init()`) and the application wants to make use of any
702/// newly-installed plugins without restarting the application.
703///
704/// Applications should assume that the registry update is neither atomic nor
705/// thread-safe and should therefore not have any dynamic pipelines running
706/// (including the playbin and decodebin elements) and should also not create
707/// any elements or access the GStreamer registry while the update is in
708/// progress.
709///
710/// Note that this function may block for a significant amount of time.
711///
712/// # Returns
713///
714/// [`true`] if the registry has been updated successfully (does not
715///  imply that there were changes), otherwise [`false`].
716#[doc(alias = "gst_update_registry")]
717pub fn update_registry() -> Result<(), glib::error::BoolError> {
718    assert_initialized_main_thread!();
719    unsafe {
720        glib::result_from_gboolean!(ffi::gst_update_registry(), "Failed to update the registry")
721    }
722}
723
724/// Get a timestamp as GstClockTime to be used for interval measurements.
725/// The timestamp should not be interpreted in any other way.
726///
727/// # Returns
728///
729/// the timestamp
730#[doc(alias = "gst_util_get_timestamp")]
731pub fn util_get_timestamp() -> ClockTime {
732    skip_assert_initialized!();
733    unsafe { try_from_glib(ffi::gst_util_get_timestamp()).expect("mandatory glib value is None") }
734}
735
736/// Gets the version number of the GStreamer library.
737///
738/// # Returns
739///
740///
741/// ## `major`
742/// pointer to a guint to store the major version number
743///
744/// ## `minor`
745/// pointer to a guint to store the minor version number
746///
747/// ## `micro`
748/// pointer to a guint to store the micro version number
749///
750/// ## `nano`
751/// pointer to a guint to store the nano version number
752#[doc(alias = "gst_version")]
753pub fn version() -> (u32, u32, u32, u32) {
754    skip_assert_initialized!();
755    unsafe {
756        let mut major = std::mem::MaybeUninit::uninit();
757        let mut minor = std::mem::MaybeUninit::uninit();
758        let mut micro = std::mem::MaybeUninit::uninit();
759        let mut nano = std::mem::MaybeUninit::uninit();
760        ffi::gst_version(
761            major.as_mut_ptr(),
762            minor.as_mut_ptr(),
763            micro.as_mut_ptr(),
764            nano.as_mut_ptr(),
765        );
766        (
767            major.assume_init(),
768            minor.assume_init(),
769            micro.assume_init(),
770            nano.assume_init(),
771        )
772    }
773}
774
775/// This function returns a string that is useful for describing this version
776/// of GStreamer to the outside world: user agent strings, logging, ...
777///
778/// # Returns
779///
780/// a newly allocated string describing this version
781///  of GStreamer.
782#[doc(alias = "gst_version_string")]
783pub fn version_string() -> glib::GString {
784    skip_assert_initialized!();
785    unsafe { from_glib_full(ffi::gst_version_string()) }
786}