gstreamer_editing_services/
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
8use std::sync::Once;
9
10pub use gio;
11pub use glib;
12use glib::translate::from_glib;
13pub use gst;
14pub use gst_base;
15pub use gst_pbutils;
16pub use gstreamer_editing_services_sys as ffi;
17
18static GES_INIT: Once = Once::new();
19
20#[doc(alias = "ges_init")]
21pub fn init() -> Result<(), glib::BoolError> {
22    if gst::init().is_err() {
23        return Err(glib::bool_error!("Could not initialize GStreamer."));
24    }
25
26    unsafe {
27        if from_glib(ffi::ges_init()) {
28            Ok(())
29        } else {
30            Err(glib::bool_error!("Could not initialize GES."))
31        }
32    }
33}
34
35pub unsafe fn deinit() {
36    ffi::ges_deinit();
37}
38
39macro_rules! assert_initialized_main_thread {
40    () => {
41        if !gst::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) {
42            gst::assert_initialized();
43        }
44        crate::GES_INIT.call_once(|| {
45            unsafe { ffi::ges_init() };
46        });
47    };
48}
49
50macro_rules! skip_assert_initialized {
51    () => {};
52}
53
54#[allow(clippy::needless_borrow)]
55#[allow(deprecated)]
56#[allow(unused_imports)]
57mod auto;
58mod formatter;
59pub use crate::auto::*;
60#[cfg(feature = "v1_24")]
61#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
62mod composition_meta;
63pub mod subclass;
64mod uri_clip_asset;
65
66#[cfg(feature = "serde")]
67mod flag_serde;
68
69// Re-export all the traits in a prelude module, so that applications
70// can always "use ges::prelude::*" without getting conflicts
71pub mod prelude {
72    #[doc(hidden)]
73    pub use glib::prelude::*;
74
75    #[doc(hidden)]
76    pub use gio::prelude::*;
77
78    #[doc(hidden)]
79    pub use gst_base::prelude::*;
80    #[doc(hidden)]
81    pub use gst_pbutils::prelude::*;
82
83    pub use crate::auto::traits::*;
84    #[cfg(feature = "v1_24")]
85    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
86    pub use crate::composition_meta::FrameCompositionMeta;
87    pub use crate::formatter::FormatterExtManual;
88}