diff --git a/Gir_GstEditingServices.toml b/Gir_GstEditingServices.toml index 76213ca60..9b945a03c 100644 --- a/Gir_GstEditingServices.toml +++ b/Gir_GstEditingServices.toml @@ -201,10 +201,6 @@ status = "generate" [object.function.return] bool_return_is_error = "Failed to unproxy asset" - [[object.function]] - name = "request_async" - ignore = true # manual skip_assert_initialized - [[object]] name = "GES.Clip" status = "generate" diff --git a/gstreamer-editing-services/src/asset.rs b/gstreamer-editing-services/src/asset.rs deleted file mode 100644 index c7d54d894..000000000 --- a/gstreamer-editing-services/src/asset.rs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2020 Guillaume Gomez -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use gio; -use glib; -use glib::prelude::*; -use glib::translate::*; -use std::boxed::Box as Box_; -use std::pin::Pin; -use std::ptr; -use Asset; - -impl Asset { - pub fn request_async< - P: IsA, - Q: FnOnce(Result) + Send + 'static, - >( - extractable_type: glib::types::Type, - id: &str, - cancellable: Option<&P>, - callback: Q, - ) { - assert_initialized_main_thread!(); - let user_data: Box_ = Box_::new(callback); - unsafe extern "C" fn request_async_trampoline< - Q: FnOnce(Result) + Send + 'static, - >( - _source_object: *mut gobject_sys::GObject, - res: *mut gio_sys::GAsyncResult, - user_data: glib_sys::gpointer, - ) { - let mut error = ptr::null_mut(); - let ret = ges_sys::ges_asset_request_finish(res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_ = Box_::from_raw(user_data as *mut _); - callback(result); - } - let callback = request_async_trampoline::; - unsafe { - ges_sys::ges_asset_request_async( - extractable_type.to_glib(), - id.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn request_async_future( - extractable_type: glib::types::Type, - id: &str, - ) -> Pin> + 'static>> { - skip_assert_initialized!(); - let id = String::from(id); - Box_::pin(gio::GioFuture::new(&(), move |_obj, send| { - let cancellable = gio::Cancellable::new(); - Self::request_async(extractable_type, &id, Some(&cancellable), move |res| { - send.resolve(res); - }); - - cancellable - })) - } -} diff --git a/gstreamer-editing-services/src/auto/asset.rs b/gstreamer-editing-services/src/auto/asset.rs index 68a24f1ba..106db93d0 100644 --- a/gstreamer-editing-services/src/auto/asset.rs +++ b/gstreamer-editing-services/src/auto/asset.rs @@ -56,6 +56,61 @@ impl Asset { } } } + + pub fn request_async< + P: IsA, + Q: FnOnce(Result) + Send + 'static, + >( + extractable_type: glib::types::Type, + id: &str, + cancellable: Option<&P>, + callback: Q, + ) { + assert_initialized_main_thread!(); + let user_data: Box_ = Box_::new(callback); + unsafe extern "C" fn request_async_trampoline< + Q: FnOnce(Result) + Send + 'static, + >( + _source_object: *mut gobject_sys::GObject, + res: *mut gio_sys::GAsyncResult, + user_data: glib_sys::gpointer, + ) { + let mut error = ptr::null_mut(); + let ret = ges_sys::ges_asset_request_finish(res, &mut error); + let result = if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + }; + let callback: Box_ = Box_::from_raw(user_data as *mut _); + callback(result); + } + let callback = request_async_trampoline::; + unsafe { + ges_sys::ges_asset_request_async( + extractable_type.to_glib(), + id.to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, + Some(callback), + Box_::into_raw(user_data) as *mut _, + ); + } + } + + pub fn request_async_future( + extractable_type: glib::types::Type, + id: &str, + ) -> Pin> + 'static>> { + let id = String::from(id); + Box_::pin(gio::GioFuture::new(&(), move |_obj, send| { + let cancellable = gio::Cancellable::new(); + Self::request_async(extractable_type, &id, Some(&cancellable), move |res| { + send.resolve(res); + }); + + cancellable + })) + } } pub const NONE_ASSET: Option<&Asset> = None; diff --git a/gstreamer-editing-services/src/lib.rs b/gstreamer-editing-services/src/lib.rs index 45eb3df50..1f3b6d825 100644 --- a/gstreamer-editing-services/src/lib.rs +++ b/gstreamer-editing-services/src/lib.rs @@ -75,7 +75,6 @@ pub use auto::*; #[macro_use] extern crate bitflags; -mod asset; mod timeline_element; pub use timeline_element::TimelineElementExtManual;