gstreamer_validate/
lib.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3#![cfg_attr(docsrs, feature(doc_cfg))]
4#![allow(clippy::missing_safety_doc)]
5#![allow(clippy::manual_c_str_literals)]
6#![doc = include_str!("../README.md")]
7
8pub use gstreamer_validate_sys as ffi;
9
10#[doc(hidden)]
11pub static INITIALIZED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
12
13#[cold]
14#[inline(never)]
15#[track_caller]
16pub fn assert_initialized() {
17    if unsafe { ffi::gst_validate_is_initialized() } != glib::ffi::GTRUE {
18        panic!("GStreamer Validate has not been initialized. Call `gst_validate::init` first.");
19    } else {
20        crate::INITIALIZED.store(true, std::sync::atomic::Ordering::SeqCst);
21    }
22}
23
24macro_rules! assert_initialized_main_thread {
25    () => {
26        if !gst::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) {
27            gst::assert_initialized();
28        }
29
30        if !crate::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) {
31            $crate::assert_initialized();
32        }
33    };
34}
35
36macro_rules! skip_assert_initialized {
37    () => {};
38}
39
40#[allow(clippy::needless_borrow)]
41#[allow(unused_imports)]
42mod auto;
43pub use crate::auto::*;
44
45mod functions;
46pub use functions::*;
47
48mod action_type;
49pub use action_type::*;
50
51mod enums;
52pub use enums::*;
53
54mod action;
55pub use action::{Action, ActionRef};
56
57mod reporter;
58
59// Re-export all the traits in a prelude module, so that applications
60// can always "use gst_validate::prelude::*" without getting conflicts
61pub mod prelude {
62    #[doc(hidden)]
63    pub use gst::prelude::*;
64
65    pub use crate::action_type::ActionTypeExtManual;
66    pub use crate::auto::traits::*;
67}