ges: Update manual code to 2018 edition

This commit is contained in:
Sebastian Dröge 2020-11-22 12:16:22 +02:00
parent 96782e8a8e
commit 3c8e798f73
3 changed files with 29 additions and 50 deletions

View file

@ -11,33 +11,30 @@ homepage = "https://gstreamer.freedesktop.org"
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_editing_services/"
keywords = ["gstreamer", "multimedia", "gnome", "nle"]
build = "build.rs"
edition = "2018"
[dependencies]
libc = "0.2"
bitflags = "1.0"
glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
gio-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer-sys = { path = "../gstreamer/sys", features = ["v1_8"] }
gstreamer-editing-services-sys = { path = "../gstreamer-editing-services/sys", features = ["v1_8"]}
ffi = { package = "gstreamer-editing-services-sys", path = "../gstreamer-editing-services/sys", features = ["v1_8"]}
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
gio = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer = { path = "../gstreamer" }
gstreamer-base = { path = "../gstreamer-base" }
gstreamer-pbutils = { path = "../gstreamer-pbutils" }
gst = { package = "gstreamer", path = "../gstreamer" }
gst-base = { package = "gstreamer-base", path = "../gstreamer-base" }
gst-pbutils = { package = "gstreamer-pbutils", path = "../gstreamer-pbutils" }
[build-dependencies]
gstreamer-rs-lgpl-docs = { path = "../docs", optional = true }
[features]
v1_10 = ["gstreamer/v1_10", "gstreamer-base/v1_10", "gstreamer-pbutils/v1_10", "gstreamer-editing-services-sys/v1_10"]
v1_12 = ["gstreamer/v1_12", "gstreamer-base/v1_12", "gstreamer-pbutils/v1_12", "gstreamer-editing-services-sys/v1_12", "v1_10"]
v1_14 = ["gstreamer/v1_14", "gstreamer-base/v1_14", "gstreamer-pbutils/v1_14", "gstreamer-editing-services-sys/v1_14", "v1_12"]
v1_16 = ["gstreamer/v1_16", "gstreamer-base/v1_16", "gstreamer-pbutils/v1_16", "gstreamer-editing-services-sys/v1_16", "v1_14"]
v1_18 = ["gstreamer/v1_18", "gstreamer-base/v1_18", "gstreamer-pbutils/v1_18", "gstreamer-editing-services-sys/v1_18", "v1_16"]
v1_10 = ["gst/v1_10", "gst-base/v1_10", "gst-pbutils/v1_10", "ffi/v1_10"]
v1_12 = ["gst/v1_12", "gst-base/v1_12", "gst-pbutils/v1_12", "ffi/v1_12", "v1_10"]
v1_14 = ["gst/v1_14", "gst-base/v1_14", "gst-pbutils/v1_14", "ffi/v1_14", "v1_12"]
v1_16 = ["gst/v1_16", "gst-base/v1_16", "gst-pbutils/v1_16", "ffi/v1_16", "v1_14"]
v1_18 = ["gst/v1_18", "gst-base/v1_18", "gst-pbutils/v1_18", "ffi/v1_18", "v1_16"]
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
dox = ["v1_18", "gstreamer-editing-services-sys/dox", "glib/dox", "gio/dox", "gstreamer/dox", "gstreamer-base/dox", "gstreamer-pbutils/dox"]
dox = ["v1_18", "ffi/dox", "glib/dox", "gio/dox", "gst/dox", "gst-base/dox", "gst-pbutils/dox"]
[package.metadata.docs.rs]
features = ["dox", "embed-lgpl-docs"]

View file

@ -8,52 +8,39 @@
#![cfg_attr(feature = "dox", feature(doc_cfg))]
extern crate libc;
pub use ffi;
use std::sync::Once;
extern crate gio_sys;
extern crate glib_sys;
extern crate gobject_sys;
extern crate gstreamer as gst;
extern crate gstreamer_base as gst_base;
extern crate gstreamer_editing_services_sys as ges_sys;
extern crate gstreamer_pbutils as gst_pbutils;
extern crate gstreamer_sys as gst_sys;
use glib::translate::from_glib;
#[macro_use]
extern crate glib;
extern crate gio;
static GES_INIT: Once = Once::new();
pub fn init() -> Result<(), glib::BoolError> {
if gst::init().is_err() {
return Err(glib_bool_error!("Could not initialize GStreamer."));
return Err(glib::glib_bool_error!("Could not initialize GStreamer."));
}
unsafe {
if from_glib(ges_sys::ges_init()) {
if from_glib(ffi::ges_init()) {
Ok(())
} else {
Err(glib_bool_error!("Could not initialize GES."))
Err(glib::glib_bool_error!("Could not initialize GES."))
}
}
}
pub unsafe fn deinit() {
ges_sys::ges_deinit();
ffi::ges_deinit();
}
macro_rules! assert_initialized_main_thread {
() => {
if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE {
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
}
::GES_INIT.call_once(|| {
unsafe { ::ges_sys::ges_init() };
crate::GES_INIT.call_once(|| {
unsafe { ffi::ges_init() };
});
};
}
@ -67,20 +54,17 @@ macro_rules! skip_assert_initialized {
#[allow(clippy::match_same_arms)]
#[allow(unused_imports)]
mod auto;
pub use auto::*;
#[macro_use]
extern crate bitflags;
pub use crate::auto::*;
mod timeline_element;
pub use timeline_element::TimelineElementExtManual;
pub use crate::timeline_element::TimelineElementExtManual;
// Re-export all the traits in a prelude module, so that applications
// can always "use gst::prelude::*" without getting conflicts
pub mod prelude {
pub use crate::timeline_element::TimelineElementExtManual;
pub use glib::prelude::*;
pub use gst::prelude::*;
pub use timeline_element::TimelineElementExtManual;
pub use auto::traits::*;
pub use crate::auto::traits::*;
}

View file

@ -6,12 +6,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ges_sys;
use glib;
use crate::TimelineElement;
use glib::object::IsA;
use glib::translate::*;
use std::ptr;
use TimelineElement;
pub trait TimelineElementExtManual: 'static {
fn get_child_property(&self, name: &str) -> Option<glib::Value>;
@ -25,7 +23,7 @@ pub trait TimelineElementExtManual: 'static {
impl<O: IsA<TimelineElement>> TimelineElementExtManual for O {
fn get_child_property(&self, name: &str) -> Option<glib::Value> {
unsafe {
let found: bool = from_glib(ges_sys::ges_timeline_element_lookup_child(
let found: bool = from_glib(ffi::ges_timeline_element_lookup_child(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
ptr::null_mut(),
@ -36,7 +34,7 @@ impl<O: IsA<TimelineElement>> TimelineElementExtManual for O {
}
let mut value = glib::Value::uninitialized();
ges_sys::ges_timeline_element_get_child_property(
ffi::ges_timeline_element_get_child_property(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none_mut().0,
@ -51,18 +49,18 @@ impl<O: IsA<TimelineElement>> TimelineElementExtManual for O {
value: &dyn glib::ToValue,
) -> Result<(), glib::BoolError> {
unsafe {
let found: bool = from_glib(ges_sys::ges_timeline_element_lookup_child(
let found: bool = from_glib(ffi::ges_timeline_element_lookup_child(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
ptr::null_mut(),
ptr::null_mut(),
));
if !found {
return Err(glib_bool_error!("Child property not found"));
return Err(glib::glib_bool_error!("Child property not found"));
}
let value = value.to_value();
ges_sys::ges_timeline_element_set_child_property(
ffi::ges_timeline_element_set_child_property(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none().0,