From 21888daab627fab1743f3aa4b3720950475e82a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 29 Jul 2017 14:19:15 +0100 Subject: [PATCH] Add GhostPad bindings --- Gir_Gst.toml | 34 +++++++++++++ gstreamer/src/auto/ghost_pad.rs | 89 +++++++++++++++++++++++++++++++++ gstreamer/src/auto/mod.rs | 10 ++++ gstreamer/src/auto/proxy_pad.rs | 45 +++++++++++++++++ gstreamer/src/ghost_pad.rs | 35 +++++++++++++ gstreamer/src/lib.rs | 2 + gstreamer/src/proxy_pad.rs | 43 ++++++++++++++++ 7 files changed, 258 insertions(+) create mode 100644 gstreamer/src/auto/ghost_pad.rs create mode 100644 gstreamer/src/auto/proxy_pad.rs create mode 100644 gstreamer/src/ghost_pad.rs create mode 100644 gstreamer/src/proxy_pad.rs diff --git a/Gir_Gst.toml b/Gir_Gst.toml index 3fb1e5d30..3a98ceb1c 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -366,6 +366,40 @@ status = "generate" # Correct mutability ignore = true +[[object]] +name = "Gst.GhostPad" +status = "generate" + [[object.function]] + name = "set_target" + [object.function.return] + bool_return_is_error = "Failed to set target" + + [[object.function]] + name = "new" + ignore = true + + [[object.function]] + name = "new_from_template" + ignore = true + + [[object.function]] + name = "construct" + ignore = true + +[[object]] +name = "Gst.ProxyPad" +status = "generate" + + [[object.function]] + name = "chain_default" + # Buffer move + ignore = true + + [[object.function]] + name = "getrange_default" + # Buffer move + ignore = true + [[object]] name = "Gst.Stream" status = "generate" diff --git a/gstreamer/src/auto/ghost_pad.rs b/gstreamer/src/auto/ghost_pad.rs new file mode 100644 index 000000000..2a0cdfe3a --- /dev/null +++ b/gstreamer/src/auto/ghost_pad.rs @@ -0,0 +1,89 @@ +// This file was generated by gir (a01311c+) from gir-files (???) +// DO NOT EDIT + +use Object; +use Pad; +use PadDirection; +use PadMode; +use PadTemplate; +use ProxyPad; +use ffi; +use glib; +use glib::object::Downcast; +use glib::object::IsA; +use glib::translate::*; +use glib_ffi; +use gobject_ffi; +use std::mem; +use std::ptr; + +glib_wrapper! { + pub struct GhostPad(Object): ProxyPad, Pad, Object; + + match fn { + get_type => || ffi::gst_ghost_pad_get_type(), + } +} + +impl GhostPad { + pub fn new_no_target<'a, P: Into>>(name: P, dir: PadDirection) -> GhostPad { + assert_initialized_main_thread!(); + let name = name.into(); + let name = name.to_glib_none(); + unsafe { + Pad::from_glib_none(ffi::gst_ghost_pad_new_no_target(name.0, dir.to_glib())).downcast_unchecked() + } + } + + pub fn new_no_target_from_template<'a, P: Into>>(name: P, templ: &PadTemplate) -> GhostPad { + skip_assert_initialized!(); + let name = name.into(); + let name = name.to_glib_none(); + unsafe { + Pad::from_glib_none(ffi::gst_ghost_pad_new_no_target_from_template(name.0, templ.to_glib_none().0)).downcast_unchecked() + } + } + + pub fn activate_mode_default<'a, P: IsA, Q: IsA + 'a, R: Into>>(pad: &P, parent: R, mode: PadMode, active: bool) -> bool { + skip_assert_initialized!(); + let parent = parent.into(); + let parent = parent.to_glib_none(); + unsafe { + from_glib(ffi::gst_ghost_pad_activate_mode_default(pad.to_glib_none().0, parent.0, mode.to_glib(), active.to_glib())) + } + } + + pub fn internal_activate_mode_default<'a, P: IsA, Q: IsA + 'a, R: Into>>(pad: &P, parent: R, mode: PadMode, active: bool) -> bool { + skip_assert_initialized!(); + let parent = parent.into(); + let parent = parent.to_glib_none(); + unsafe { + from_glib(ffi::gst_ghost_pad_internal_activate_mode_default(pad.to_glib_none().0, parent.0, mode.to_glib(), active.to_glib())) + } + } +} + +unsafe impl Send for GhostPad {} +unsafe impl Sync for GhostPad {} + +pub trait GhostPadExt { + fn get_target(&self) -> Option; + + fn set_target<'a, P: IsA + 'a, Q: Into>>(&self, newtarget: Q) -> Result<(), glib::error::BoolError>; +} + +impl> GhostPadExt for O { + fn get_target(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_ghost_pad_get_target(self.to_glib_none().0)) + } + } + + fn set_target<'a, P: IsA + 'a, Q: Into>>(&self, newtarget: Q) -> Result<(), glib::error::BoolError> { + let newtarget = newtarget.into(); + let newtarget = newtarget.to_glib_none(); + unsafe { + glib::error::BoolError::from_glib(ffi::gst_ghost_pad_set_target(self.to_glib_none().0, newtarget.0), "Failed to set target") + } + } +} diff --git a/gstreamer/src/auto/mod.rs b/gstreamer/src/auto/mod.rs index efb66029c..8a7f8e591 100644 --- a/gstreamer/src/auto/mod.rs +++ b/gstreamer/src/auto/mod.rs @@ -35,6 +35,10 @@ pub use self::element::ElementExt; mod element_factory; pub use self::element_factory::ElementFactory; +mod ghost_pad; +pub use self::ghost_pad::GhostPad; +pub use self::ghost_pad::GhostPadExt; + mod object; pub use self::object::Object; pub use self::object::ObjectExt; @@ -54,6 +58,10 @@ pub use self::pipeline::PipelineExt; mod plugin; pub use self::plugin::Plugin; +mod proxy_pad; +pub use self::proxy_pad::ProxyPad; +pub use self::proxy_pad::ProxyPadExt; + #[cfg(feature = "v1_10")] mod stream; #[cfg(feature = "v1_10")] @@ -193,10 +201,12 @@ pub mod traits { pub use super::DeviceProviderExt; pub use super::DeviceProviderFactoryExt; pub use super::ElementExt; + pub use super::GhostPadExt; pub use super::ObjectExt; pub use super::PadExt; pub use super::PadTemplateExt; pub use super::PipelineExt; + pub use super::ProxyPadExt; #[cfg(feature = "v1_10")] pub use super::StreamExt; #[cfg(feature = "v1_10")] diff --git a/gstreamer/src/auto/proxy_pad.rs b/gstreamer/src/auto/proxy_pad.rs new file mode 100644 index 000000000..e814c7c6a --- /dev/null +++ b/gstreamer/src/auto/proxy_pad.rs @@ -0,0 +1,45 @@ +// This file was generated by gir (a01311c+) from gir-files (???) +// DO NOT EDIT + +use Object; +use Pad; +use ffi; +use glib::object::IsA; +use glib::translate::*; +use glib_ffi; +use gobject_ffi; +use std::mem; +use std::ptr; + +glib_wrapper! { + pub struct ProxyPad(Object): Pad, Object; + + match fn { + get_type => || ffi::gst_proxy_pad_get_type(), + } +} + +impl ProxyPad { + //pub fn chain_list_default<'a, P: IsA, Q: IsA + 'a, R: Into>>(pad: &P, parent: R, list: /*Ignored*/&mut BufferList) -> FlowReturn { + // unsafe { TODO: call ffi::gst_proxy_pad_chain_list_default() } + //} + + //pub fn iterate_internal_links_default<'a, P: IsA, Q: IsA + 'a, R: Into>>(pad: &P, parent: R) -> /*Ignored*/Option { + // unsafe { TODO: call ffi::gst_proxy_pad_iterate_internal_links_default() } + //} +} + +unsafe impl Send for ProxyPad {} +unsafe impl Sync for ProxyPad {} + +pub trait ProxyPadExt { + fn get_internal(&self) -> Option; +} + +impl> ProxyPadExt for O { + fn get_internal(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_proxy_pad_get_internal(self.to_glib_none().0)) + } + } +} diff --git a/gstreamer/src/ghost_pad.rs b/gstreamer/src/ghost_pad.rs new file mode 100644 index 000000000..a0fb9b2f9 --- /dev/null +++ b/gstreamer/src/ghost_pad.rs @@ -0,0 +1,35 @@ +// Copyright (C) 2017 Sebastian Dröge +// +// 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 Pad; +use PadTemplate; +use GhostPad; +use ffi; +use glib::object::Downcast; +use glib::object::IsA; +use glib::translate::*; + +impl GhostPad { + pub fn new<'a, P: Into>, Q: IsA>(name: P, target: &Q) -> Option { + skip_assert_initialized!(); + let name = name.into(); + let name = name.to_glib_none(); + unsafe { + Option::::from_glib_none(ffi::gst_ghost_pad_new(name.0, target.to_glib_none().0)).map(|o| Downcast::downcast_unchecked(o)) + } + } + + pub fn new_from_template<'a, P: Into>, Q: IsA>(name: P, target: &Q, templ: &PadTemplate) -> Option { + skip_assert_initialized!(); + let name = name.into(); + let name = name.to_glib_none(); + unsafe { + Option::::from_glib_none(ffi::gst_ghost_pad_new_from_template(name.0, target.to_glib_none().0, templ.to_glib_none().0)).map(|o| Downcast::downcast_unchecked(o)) + } + } +} diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 83aaca921..46759f5f2 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -71,6 +71,8 @@ mod bus; mod pad; mod gobject; mod segment; +mod proxy_pad; +mod ghost_pad; pub use element::ElementExtManual; pub use bin::BinExtManual; pub use pad::{PadExtManual, PadProbeId, PadProbeInfo, PadProbeData, PAD_PROBE_ID_INVALID}; diff --git a/gstreamer/src/proxy_pad.rs b/gstreamer/src/proxy_pad.rs new file mode 100644 index 000000000..23f166ec6 --- /dev/null +++ b/gstreamer/src/proxy_pad.rs @@ -0,0 +1,43 @@ +// Copyright (C) 2017 Sebastian Dröge +// +// 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 std::ptr; +use Pad; +use ProxyPad; +use Object; +use FlowReturn; +use Buffer; + +use glib::IsA; +use glib::translate::{ToGlibPtr, from_glib, from_glib_full}; + +use ffi; + +impl ProxyPad { + pub fn chain_default<'a, P: IsA, Q: IsA + 'a, R: Into>>(pad: &P, parent: R, buffer: Buffer) -> FlowReturn { + skip_assert_initialized!(); + let parent = parent.into(); + let parent = parent.to_glib_none(); + unsafe { + from_glib(ffi::gst_proxy_pad_chain_default(pad.to_glib_none().0, parent.0, buffer.into_ptr())) + } + } + + pub fn getrange_default, Q: IsA>(pad: &P, parent: &Q, offset: u64, size: u32) -> Result { + skip_assert_initialized!(); + unsafe { + let mut buffer = ptr::null_mut(); + let ret = from_glib(ffi::gst_proxy_pad_getrange_default(pad.to_glib_none().0, parent.to_glib_none().0, offset, size, &mut buffer)); + if ret == FlowReturn::Ok { + Ok(from_glib_full(buffer)) + } else { + Err(ret) + } + } + } +}