Skip to main content

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    unsafe {
37        ffi::ges_deinit();
38    }
39}
40
41macro_rules! assert_initialized_main_thread {
42    () => {
43        if !gst::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) {
44            gst::assert_initialized();
45        }
46        crate::GES_INIT.call_once(|| {
47            unsafe { ffi::ges_init() };
48        });
49    };
50}
51
52macro_rules! skip_assert_initialized {
53    () => {};
54}
55
56mod asset;
57#[allow(clippy::needless_borrow)]
58#[allow(deprecated)]
59#[allow(unused_imports)]
60#[allow(clippy::let_and_return)]
61mod auto;
62mod formatter;
63pub use crate::auto::*;
64#[cfg(feature = "v1_24")]
65#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
66mod composition_meta;
67pub mod subclass;
68mod timeline_element;
69mod uri_clip_asset;
70
71#[cfg(feature = "serde")]
72mod flag_serde;
73
74// Re-export all the traits in a prelude module, so that applications
75// can always "use ges::prelude::*" without getting conflicts
76pub mod prelude {
77    #[doc(hidden)]
78    pub use glib::prelude::*;
79
80    #[doc(hidden)]
81    pub use gio::prelude::*;
82
83    #[doc(hidden)]
84    pub use gst_base::prelude::*;
85    #[doc(hidden)]
86    pub use gst_pbutils::prelude::*;
87
88    pub use crate::auto::traits::*;
89    #[cfg(feature = "v1_24")]
90    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
91    pub use crate::composition_meta::FrameCompositionMeta;
92    pub use crate::formatter::FormatterExtManual;
93    pub use crate::timeline_element::TimelineElementExtManual;
94}