// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::Bus; use crate::Caps; use crate::Clock; use crate::ClockTime; use crate::Context; use crate::ElementFactory; use crate::Object; use crate::Pad; use crate::PadLinkCheck; use crate::PadTemplate; use crate::URIType; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::mem::transmute; use std::ptr; glib::wrapper! { pub struct Element(Object) @extends Object; match fn { type_ => || ffi::gst_element_get_type(), } } impl Element { #[doc(alias = "gst_element_make_from_uri")] pub fn make_from_uri( type_: URIType, uri: &str, elementname: Option<&str>, ) -> Result { assert_initialized_main_thread!(); unsafe { let mut error = ptr::null_mut(); let ret = ffi::gst_element_make_from_uri( type_.to_glib(), uri.to_glib_none().0, elementname.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_none(ret)) } else { Err(from_glib_full(error)) } } } } unsafe impl Send for Element {} unsafe impl Sync for Element {} pub const NONE_ELEMENT: Option<&Element> = None; pub trait ElementExt: 'static { #[doc(alias = "gst_element_abort_state")] fn abort_state(&self); #[doc(alias = "gst_element_add_pad")] fn add_pad>(&self, pad: &P) -> Result<(), glib::error::BoolError>; #[doc(alias = "gst_element_create_all_pads")] fn create_all_pads(&self); #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] #[doc(alias = "gst_element_foreach_pad")] fn foreach_pad bool>(&self, func: P) -> bool; #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] #[doc(alias = "gst_element_foreach_sink_pad")] fn foreach_sink_pad bool>(&self, func: P) -> bool; #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] #[doc(alias = "gst_element_foreach_src_pad")] fn foreach_src_pad bool>(&self, func: P) -> bool; #[doc(alias = "gst_element_get_base_time")] fn base_time(&self) -> ClockTime; #[doc(alias = "gst_element_get_bus")] fn bus(&self) -> Option; #[doc(alias = "gst_element_get_clock")] fn clock(&self) -> Option; #[doc(alias = "gst_element_get_compatible_pad")] fn compatible_pad>(&self, pad: &P, caps: Option<&Caps>) -> Option; #[doc(alias = "gst_element_get_compatible_pad_template")] fn compatible_pad_template(&self, compattempl: &PadTemplate) -> Option; #[doc(alias = "gst_element_get_context")] fn context(&self, context_type: &str) -> Option; #[doc(alias = "gst_element_get_contexts")] fn contexts(&self) -> Vec; #[doc(alias = "gst_element_get_factory")] fn factory(&self) -> Option; #[doc(alias = "gst_element_get_request_pad")] fn request_pad_simple(&self, name: &str) -> Option; #[doc(alias = "gst_element_get_start_time")] fn start_time(&self) -> ClockTime; #[doc(alias = "gst_element_get_static_pad")] fn static_pad(&self, name: &str) -> Option; #[doc(alias = "gst_element_is_locked_state")] fn is_locked_state(&self) -> bool; //#[doc(alias = "gst_element_iterate_pads")] //fn iterate_pads(&self) -> /*Ignored*/Iterator; //#[doc(alias = "gst_element_iterate_sink_pads")] //fn iterate_sink_pads(&self) -> /*Ignored*/Iterator; //#[doc(alias = "gst_element_iterate_src_pads")] //fn iterate_src_pads(&self) -> /*Ignored*/Iterator; #[doc(alias = "gst_element_link")] fn link>(&self, dest: &P) -> Result<(), glib::error::BoolError>; #[doc(alias = "gst_element_link_filtered")] fn link_filtered>( &self, dest: &P, filter: Option<&Caps>, ) -> Result<(), glib::error::BoolError>; //#[doc(alias = "gst_element_link_many")] //fn link_many>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool; #[doc(alias = "gst_element_link_pads")] fn link_pads>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, ) -> Result<(), glib::error::BoolError>; #[doc(alias = "gst_element_link_pads_filtered")] fn link_pads_filtered>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, filter: Option<&Caps>, ) -> Result<(), glib::error::BoolError>; #[doc(alias = "gst_element_link_pads_full")] fn link_pads_full>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, flags: PadLinkCheck, ) -> Result<(), glib::error::BoolError>; #[doc(alias = "gst_element_lost_state")] fn lost_state(&self); //#[doc(alias = "gst_element_message_full")] //fn message_full(&self, type_: /*Ignored*/MessageType, domain: glib::Quark, code: i32, text: Option<&str>, debug: Option<&str>, file: &str, function: &str, line: i32); //#[cfg(any(feature = "v1_10", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] //#[doc(alias = "gst_element_message_full_with_details")] //fn message_full_with_details(&self, type_: /*Ignored*/MessageType, domain: glib::Quark, code: i32, text: Option<&str>, debug: Option<&str>, file: &str, function: &str, line: i32, structure: &mut Structure); #[doc(alias = "gst_element_no_more_pads")] fn no_more_pads(&self); #[doc(alias = "gst_element_provide_clock")] fn provide_clock(&self) -> Option; #[doc(alias = "gst_element_release_request_pad")] fn release_request_pad>(&self, pad: &P); #[doc(alias = "gst_element_remove_pad")] fn remove_pad>(&self, pad: &P) -> Result<(), glib::error::BoolError>; #[doc(alias = "gst_element_request_pad")] fn request_pad( &self, templ: &PadTemplate, name: Option<&str>, caps: Option<&Caps>, ) -> Option; #[doc(alias = "gst_element_set_base_time")] fn set_base_time(&self, time: ClockTime); #[doc(alias = "gst_element_set_bus")] fn set_bus(&self, bus: Option<&Bus>); #[doc(alias = "gst_element_set_clock")] fn set_clock>(&self, clock: Option<&P>) -> Result<(), glib::error::BoolError>; #[doc(alias = "gst_element_set_context")] fn set_context(&self, context: &Context); #[doc(alias = "gst_element_set_locked_state")] fn set_locked_state(&self, locked_state: bool) -> bool; #[doc(alias = "gst_element_set_start_time")] fn set_start_time(&self, time: ClockTime); #[doc(alias = "gst_element_sync_state_with_parent")] fn sync_state_with_parent(&self) -> Result<(), glib::error::BoolError>; #[doc(alias = "gst_element_unlink")] fn unlink>(&self, dest: &P); //#[doc(alias = "gst_element_unlink_many")] //fn unlink_many>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); #[doc(alias = "gst_element_unlink_pads")] fn unlink_pads>(&self, srcpadname: &str, dest: &P, destpadname: &str); fn connect_no_more_pads(&self, f: F) -> SignalHandlerId; fn connect_pad_added( &self, f: F, ) -> SignalHandlerId; fn connect_pad_removed( &self, f: F, ) -> SignalHandlerId; } impl> ElementExt for O { fn abort_state(&self) { unsafe { ffi::gst_element_abort_state(self.as_ref().to_glib_none().0); } } fn add_pad>(&self, pad: &P) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_element_add_pad( self.as_ref().to_glib_none().0, pad.as_ref().to_glib_none().0 ), "Failed to add pad" ) } } fn create_all_pads(&self) { unsafe { ffi::gst_element_create_all_pads(self.as_ref().to_glib_none().0); } } #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] fn foreach_pad bool>(&self, func: P) -> bool { let func_data: P = func; unsafe extern "C" fn func_func bool>( element: *mut ffi::GstElement, pad: *mut ffi::GstPad, user_data: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let element = from_glib_borrow(element); let pad = from_glib_borrow(pad); let callback: *mut P = user_data as *const _ as usize as *mut P; let res = (*callback)(&element, &pad); res.to_glib() } let func = Some(func_func::

as _); let super_callback0: &P = &func_data; unsafe { from_glib(ffi::gst_element_foreach_pad( self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _, )) } } #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] fn foreach_sink_pad bool>(&self, func: P) -> bool { let func_data: P = func; unsafe extern "C" fn func_func bool>( element: *mut ffi::GstElement, pad: *mut ffi::GstPad, user_data: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let element = from_glib_borrow(element); let pad = from_glib_borrow(pad); let callback: *mut P = user_data as *const _ as usize as *mut P; let res = (*callback)(&element, &pad); res.to_glib() } let func = Some(func_func::

as _); let super_callback0: &P = &func_data; unsafe { from_glib(ffi::gst_element_foreach_sink_pad( self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _, )) } } #[cfg(any(feature = "v1_14", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] fn foreach_src_pad bool>(&self, func: P) -> bool { let func_data: P = func; unsafe extern "C" fn func_func bool>( element: *mut ffi::GstElement, pad: *mut ffi::GstPad, user_data: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let element = from_glib_borrow(element); let pad = from_glib_borrow(pad); let callback: *mut P = user_data as *const _ as usize as *mut P; let res = (*callback)(&element, &pad); res.to_glib() } let func = Some(func_func::

as _); let super_callback0: &P = &func_data; unsafe { from_glib(ffi::gst_element_foreach_src_pad( self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _, )) } } fn base_time(&self) -> ClockTime { unsafe { from_glib(ffi::gst_element_get_base_time( self.as_ref().to_glib_none().0, )) } } fn bus(&self) -> Option { unsafe { from_glib_full(ffi::gst_element_get_bus(self.as_ref().to_glib_none().0)) } } fn clock(&self) -> Option { unsafe { from_glib_full(ffi::gst_element_get_clock(self.as_ref().to_glib_none().0)) } } fn compatible_pad>(&self, pad: &P, caps: Option<&Caps>) -> Option { unsafe { from_glib_full(ffi::gst_element_get_compatible_pad( self.as_ref().to_glib_none().0, pad.as_ref().to_glib_none().0, caps.to_glib_none().0, )) } } fn compatible_pad_template(&self, compattempl: &PadTemplate) -> Option { unsafe { from_glib_none(ffi::gst_element_get_compatible_pad_template( self.as_ref().to_glib_none().0, compattempl.to_glib_none().0, )) } } fn context(&self, context_type: &str) -> Option { unsafe { from_glib_full(ffi::gst_element_get_context( self.as_ref().to_glib_none().0, context_type.to_glib_none().0, )) } } fn contexts(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_element_get_contexts( self.as_ref().to_glib_none().0, )) } } fn factory(&self) -> Option { unsafe { from_glib_none(ffi::gst_element_get_factory(self.as_ref().to_glib_none().0)) } } fn request_pad_simple(&self, name: &str) -> Option { unsafe { from_glib_full(ffi::gst_element_get_request_pad( self.as_ref().to_glib_none().0, name.to_glib_none().0, )) } } fn start_time(&self) -> ClockTime { unsafe { from_glib(ffi::gst_element_get_start_time( self.as_ref().to_glib_none().0, )) } } fn static_pad(&self, name: &str) -> Option { unsafe { from_glib_full(ffi::gst_element_get_static_pad( self.as_ref().to_glib_none().0, name.to_glib_none().0, )) } } fn is_locked_state(&self) -> bool { unsafe { from_glib(ffi::gst_element_is_locked_state( self.as_ref().to_glib_none().0, )) } } //fn iterate_pads(&self) -> /*Ignored*/Iterator { // unsafe { TODO: call ffi:gst_element_iterate_pads() } //} //fn iterate_sink_pads(&self) -> /*Ignored*/Iterator { // unsafe { TODO: call ffi:gst_element_iterate_sink_pads() } //} //fn iterate_src_pads(&self) -> /*Ignored*/Iterator { // unsafe { TODO: call ffi:gst_element_iterate_src_pads() } //} fn link>(&self, dest: &P) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_element_link( self.as_ref().to_glib_none().0, dest.as_ref().to_glib_none().0 ), "Failed to link elements" ) } } fn link_filtered>( &self, dest: &P, filter: Option<&Caps>, ) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_element_link_filtered( self.as_ref().to_glib_none().0, dest.as_ref().to_glib_none().0, filter.to_glib_none().0 ), "Failed to link elements" ) } } //fn link_many>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call ffi:gst_element_link_many() } //} fn link_pads>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, ) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_element_link_pads( self.as_ref().to_glib_none().0, srcpadname.to_glib_none().0, dest.as_ref().to_glib_none().0, destpadname.to_glib_none().0 ), "Failed to link pads" ) } } fn link_pads_filtered>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, filter: Option<&Caps>, ) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_element_link_pads_filtered( self.as_ref().to_glib_none().0, srcpadname.to_glib_none().0, dest.as_ref().to_glib_none().0, destpadname.to_glib_none().0, filter.to_glib_none().0 ), "Failed to link pads" ) } } fn link_pads_full>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, flags: PadLinkCheck, ) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_element_link_pads_full( self.as_ref().to_glib_none().0, srcpadname.to_glib_none().0, dest.as_ref().to_glib_none().0, destpadname.to_glib_none().0, flags.to_glib() ), "Failed to link pads" ) } } fn lost_state(&self) { unsafe { ffi::gst_element_lost_state(self.as_ref().to_glib_none().0); } } //fn message_full(&self, type_: /*Ignored*/MessageType, domain: glib::Quark, code: i32, text: Option<&str>, debug: Option<&str>, file: &str, function: &str, line: i32) { // unsafe { TODO: call ffi:gst_element_message_full() } //} //#[cfg(any(feature = "v1_10", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] //fn message_full_with_details(&self, type_: /*Ignored*/MessageType, domain: glib::Quark, code: i32, text: Option<&str>, debug: Option<&str>, file: &str, function: &str, line: i32, structure: &mut Structure) { // unsafe { TODO: call ffi:gst_element_message_full_with_details() } //} fn no_more_pads(&self) { unsafe { ffi::gst_element_no_more_pads(self.as_ref().to_glib_none().0); } } fn provide_clock(&self) -> Option { unsafe { from_glib_full(ffi::gst_element_provide_clock( self.as_ref().to_glib_none().0, )) } } fn release_request_pad>(&self, pad: &P) { unsafe { ffi::gst_element_release_request_pad( self.as_ref().to_glib_none().0, pad.as_ref().to_glib_none().0, ); } } fn remove_pad>(&self, pad: &P) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_element_remove_pad( self.as_ref().to_glib_none().0, pad.as_ref().to_glib_none().0 ), "Failed to remove pad" ) } } fn request_pad( &self, templ: &PadTemplate, name: Option<&str>, caps: Option<&Caps>, ) -> Option { unsafe { from_glib_full(ffi::gst_element_request_pad( self.as_ref().to_glib_none().0, templ.to_glib_none().0, name.to_glib_none().0, caps.to_glib_none().0, )) } } fn set_base_time(&self, time: ClockTime) { unsafe { ffi::gst_element_set_base_time(self.as_ref().to_glib_none().0, time.to_glib()); } } fn set_bus(&self, bus: Option<&Bus>) { unsafe { ffi::gst_element_set_bus(self.as_ref().to_glib_none().0, bus.to_glib_none().0); } } fn set_clock>(&self, clock: Option<&P>) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_element_set_clock( self.as_ref().to_glib_none().0, clock.map(|p| p.as_ref()).to_glib_none().0 ), "Failed to set clock" ) } } fn set_context(&self, context: &Context) { unsafe { ffi::gst_element_set_context(self.as_ref().to_glib_none().0, context.to_glib_none().0); } } fn set_locked_state(&self, locked_state: bool) -> bool { unsafe { from_glib(ffi::gst_element_set_locked_state( self.as_ref().to_glib_none().0, locked_state.to_glib(), )) } } fn set_start_time(&self, time: ClockTime) { unsafe { ffi::gst_element_set_start_time(self.as_ref().to_glib_none().0, time.to_glib()); } } fn sync_state_with_parent(&self) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_element_sync_state_with_parent(self.as_ref().to_glib_none().0), "Failed to sync state with parent" ) } } fn unlink>(&self, dest: &P) { unsafe { ffi::gst_element_unlink( self.as_ref().to_glib_none().0, dest.as_ref().to_glib_none().0, ); } } //fn unlink_many>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call ffi:gst_element_unlink_many() } //} fn unlink_pads>(&self, srcpadname: &str, dest: &P, destpadname: &str) { unsafe { ffi::gst_element_unlink_pads( self.as_ref().to_glib_none().0, srcpadname.to_glib_none().0, dest.as_ref().to_glib_none().0, destpadname.to_glib_none().0, ); } } fn connect_no_more_pads(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn no_more_pads_trampoline( this: *mut ffi::GstElement, f: glib::ffi::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Element::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"no-more-pads\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( no_more_pads_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_pad_added( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn pad_added_trampoline( this: *mut ffi::GstElement, new_pad: *mut ffi::GstPad, f: glib::ffi::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &Element::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(new_pad), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"pad-added\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( pad_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_pad_removed( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn pad_removed_trampoline( this: *mut ffi::GstElement, old_pad: *mut ffi::GstPad, f: glib::ffi::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &Element::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(old_pad), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"pad-removed\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( pad_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } }