From 3c8e798f73ae990a5f8aa949a4bea952c2f54259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 22 Nov 2020 12:16:22 +0200 Subject: [PATCH] ges: Update manual code to 2018 edition --- gstreamer-editing-services/Cargo.toml | 25 +++++------- gstreamer-editing-services/src/lib.rs | 40 ++++++------------- .../src/timeline_element.rs | 14 +++---- 3 files changed, 29 insertions(+), 50 deletions(-) diff --git a/gstreamer-editing-services/Cargo.toml b/gstreamer-editing-services/Cargo.toml index bacefc80e..6154b4982 100644 --- a/gstreamer-editing-services/Cargo.toml +++ b/gstreamer-editing-services/Cargo.toml @@ -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"] diff --git a/gstreamer-editing-services/src/lib.rs b/gstreamer-editing-services/src/lib.rs index bf3c3ae5a..d5755e085 100644 --- a/gstreamer-editing-services/src/lib.rs +++ b/gstreamer-editing-services/src/lib.rs @@ -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::*; } diff --git a/gstreamer-editing-services/src/timeline_element.rs b/gstreamer-editing-services/src/timeline_element.rs index 7d3cc1aea..db1fc059f 100644 --- a/gstreamer-editing-services/src/timeline_element.rs +++ b/gstreamer-editing-services/src/timeline_element.rs @@ -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; @@ -25,7 +23,7 @@ pub trait TimelineElementExtManual: 'static { impl> TimelineElementExtManual for O { fn get_child_property(&self, name: &str) -> Option { 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> 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> 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,