2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2018-10-31 16:10:30 +00:00
|
|
|
|
2020-11-27 13:37:49 +00:00
|
|
|
#![cfg_attr(feature = "dox", feature(doc_cfg))]
|
2020-11-18 12:48:41 +00:00
|
|
|
|
2020-11-22 10:16:22 +00:00
|
|
|
pub use ffi;
|
2020-12-20 17:39:15 +00:00
|
|
|
pub use gio;
|
|
|
|
pub use glib;
|
|
|
|
pub use gst;
|
|
|
|
pub use gst_base;
|
|
|
|
pub use gst_pbutils;
|
2018-10-31 16:10:30 +00:00
|
|
|
|
2019-07-11 13:38:24 +00:00
|
|
|
use std::sync::Once;
|
2018-10-31 16:10:30 +00:00
|
|
|
|
|
|
|
use glib::translate::from_glib;
|
|
|
|
|
2019-07-11 13:38:24 +00:00
|
|
|
static GES_INIT: Once = Once::new();
|
2018-10-31 16:10:30 +00:00
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "ges_init")]
|
2019-11-10 17:07:13 +00:00
|
|
|
pub fn init() -> Result<(), glib::BoolError> {
|
2018-10-31 16:10:30 +00:00
|
|
|
if gst::init().is_err() {
|
2020-12-17 22:38:06 +00:00
|
|
|
return Err(glib::bool_error!("Could not initialize GStreamer."));
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe {
|
2020-11-22 10:16:22 +00:00
|
|
|
if from_glib(ffi::ges_init()) {
|
2018-10-31 16:10:30 +00:00
|
|
|
Ok(())
|
|
|
|
} else {
|
2020-12-17 22:38:06 +00:00
|
|
|
Err(glib::bool_error!("Could not initialize GES."))
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub unsafe fn deinit() {
|
2020-11-22 10:16:22 +00:00
|
|
|
ffi::ges_deinit();
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! assert_initialized_main_thread {
|
|
|
|
() => {
|
2020-11-22 10:16:22 +00:00
|
|
|
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
|
2018-10-31 16:10:30 +00:00
|
|
|
panic!("GStreamer has not been initialized. Call `gst::init` first.");
|
|
|
|
}
|
2020-11-22 10:16:22 +00:00
|
|
|
crate::GES_INIT.call_once(|| {
|
|
|
|
unsafe { ffi::ges_init() };
|
2018-10-31 16:10:30 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! skip_assert_initialized {
|
|
|
|
() => {};
|
|
|
|
}
|
|
|
|
|
2019-02-28 08:32:13 +00:00
|
|
|
#[allow(clippy::unreadable_literal)]
|
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
|
|
#[allow(clippy::match_same_arms)]
|
2021-04-29 20:06:11 +00:00
|
|
|
#[allow(clippy::use_self)]
|
2018-10-31 16:10:30 +00:00
|
|
|
mod auto;
|
2020-11-22 10:16:22 +00:00
|
|
|
pub use crate::auto::*;
|
2018-10-31 16:10:30 +00:00
|
|
|
|
|
|
|
mod timeline_element;
|
|
|
|
|
|
|
|
// Re-export all the traits in a prelude module, so that applications
|
2021-04-27 07:30:13 +00:00
|
|
|
// can always "use ges::prelude::*" without getting conflicts
|
2018-10-31 16:10:30 +00:00
|
|
|
pub mod prelude {
|
2020-12-20 17:39:15 +00:00
|
|
|
#[doc(hidden)]
|
|
|
|
pub use gio::prelude::*;
|
|
|
|
#[doc(hidden)]
|
|
|
|
pub use gst_base::prelude::*;
|
|
|
|
#[doc(hidden)]
|
|
|
|
pub use gst_pbutils::prelude::*;
|
|
|
|
|
|
|
|
pub use crate::timeline_element::TimelineElementExtManual;
|
2018-10-31 16:10:30 +00:00
|
|
|
|
2020-11-22 10:16:22 +00:00
|
|
|
pub use crate::auto::traits::*;
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|