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
54mod asset;
55#[allow(clippy::needless_borrow)]
56#[allow(deprecated)]
57#[allow(unused_imports)]
58mod auto;
59mod formatter;
60pub use crate::auto::*;
61#[cfg(feature = "v1_24")]
62#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
63mod composition_meta;
64pub mod subclass;
65mod timeline_element;
66mod uri_clip_asset;
67
68#[cfg(feature = "serde")]
69mod flag_serde;
70
71// Re-export all the traits in a prelude module, so that applications
72// can always "use ges::prelude::*" without getting conflicts
73pub mod prelude {
74    #[doc(hidden)]
75    pub use glib::prelude::*;
76
77    #[doc(hidden)]
78    pub use gio::prelude::*;
79
80    #[doc(hidden)]
81    pub use gst_base::prelude::*;
82    #[doc(hidden)]
83    pub use gst_pbutils::prelude::*;
84
85    pub use crate::auto::traits::*;
86    #[cfg(feature = "v1_24")]
87    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
88    pub use crate::composition_meta::FrameCompositionMeta;
89    pub use crate::formatter::FormatterExtManual;
90    pub use crate::timeline_element::TimelineElementExtManual;
91}