diff --git a/Gir_Gst.toml b/Gir_Gst.toml index b70cc5177..e7f9585b1 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -58,7 +58,6 @@ generate = [ manual = [ "GLib.Error", "GLib.Source", - "Gst.Message", "Gst.Structure", ] @@ -117,6 +116,21 @@ name = "Gst.Caps" status = "manual" ref_mode = "ref" +[[object]] +name = "Gst.Buffer" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.Message" +status = "manual" +ref_mode = "ref" + +[[object]] +name = "Gst.TagList" +status = "manual" +ref_mode = "ref" + [[object]] name = "Gst.Clock" status = "generate" @@ -268,6 +282,26 @@ status = "generate" # Don't use a ulong ignore = true + [[object.function]] + name = "chain" + # Move buffer + ignore = true + + [[object.function]] + name = "push" + # Move buffer + ignore = true + + [[object.function]] + name = "pull_range" + # Buffer can be NULL + ignore = true + + [[object.function]] + name = "get_range" + # Buffer can be NULL + ignore = true + [[object]] name = "Gst.Stream" status = "generate" @@ -277,6 +311,11 @@ status = "generate" # Caps is not a GObject ignore = true + [[object.property]] + name = "tags" + # TagList is not a GObject + ignore = true + [[object]] name = "Gst.Plugin" status = "generate" diff --git a/gstreamer/src/auto/bus.rs b/gstreamer/src/auto/bus.rs index 60592bdbb..d593f98c0 100644 --- a/gstreamer/src/auto/bus.rs +++ b/gstreamer/src/auto/bus.rs @@ -50,7 +50,7 @@ impl Bus { // unsafe { TODO: call ffi::gst_bus_add_watch_full() } //} - //pub fn async_signal_func>>(&self, message: &mut Message, data: P) -> bool { + //pub fn async_signal_func>>(&self, message: &Message, data: P) -> bool { // unsafe { TODO: call ffi::gst_bus_async_signal_func() } //} @@ -84,7 +84,7 @@ impl Bus { } } - pub fn post(&self, message: &mut Message) -> bool { + pub fn post(&self, message: &Message) -> bool { unsafe { from_glib(ffi::gst_bus_post(self.to_glib_none().0, message.to_glib_full())) } @@ -106,7 +106,7 @@ impl Bus { // unsafe { TODO: call ffi::gst_bus_set_sync_handler() } //} - //pub fn sync_signal_handler>>(&self, message: &mut Message, data: P) -> BusSyncReply { + //pub fn sync_signal_handler>>(&self, message: &Message, data: P) -> BusSyncReply { // unsafe { TODO: call ffi::gst_bus_sync_signal_handler() } //} diff --git a/gstreamer/src/auto/element.rs b/gstreamer/src/auto/element.rs index 46bb066e2..35cf44324 100644 --- a/gstreamer/src/auto/element.rs +++ b/gstreamer/src/auto/element.rs @@ -156,7 +156,7 @@ pub trait ElementExt { fn no_more_pads(&self); - fn post_message(&self, message: &mut Message) -> bool; + fn post_message(&self, message: &Message) -> bool; fn provide_clock(&self) -> Option; @@ -426,7 +426,7 @@ impl + IsA> ElementExt for O { } } - fn post_message(&self, message: &mut Message) -> bool { + fn post_message(&self, message: &Message) -> bool { unsafe { from_glib(ffi::gst_element_post_message(self.to_glib_none().0, message.to_glib_full())) } diff --git a/gstreamer/src/auto/pad.rs b/gstreamer/src/auto/pad.rs index 29bc2b1d2..1a61eb8da 100644 --- a/gstreamer/src/auto/pad.rs +++ b/gstreamer/src/auto/pad.rs @@ -74,8 +74,6 @@ pub trait PadExt { fn can_link>(&self, sinkpad: &P) -> bool; - //fn chain(&self, buffer: /*Ignored*/&mut Buffer) -> FlowReturn; - //fn chain_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn; fn check_reconfigure(&self) -> bool; @@ -110,8 +108,6 @@ pub trait PadExt { fn get_peer(&self) -> Option; - //fn get_range(&self, offset: u64, size: u32, buffer: /*Ignored*/Buffer) -> FlowReturn; - //fn get_sticky_event(&self, event_type: /*Ignored*/EventType, idx: u32) -> /*Ignored*/Option; #[cfg(feature = "v1_10")] @@ -168,10 +164,6 @@ pub trait PadExt { //fn proxy_query_caps(&self, query: /*Ignored*/&mut Query) -> bool; - //fn pull_range(&self, offset: u64, size: u32, buffer: /*Ignored*/Buffer) -> FlowReturn; - - //fn push(&self, buffer: /*Ignored*/&mut Buffer) -> FlowReturn; - //fn push_event(&self, event: /*Ignored*/&mut Event) -> bool; //fn push_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn; @@ -256,10 +248,6 @@ impl + IsA> PadExt for O { } } - //fn chain(&self, buffer: /*Ignored*/&mut Buffer) -> FlowReturn { - // unsafe { TODO: call ffi::gst_pad_chain() } - //} - //fn chain_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn { // unsafe { TODO: call ffi::gst_pad_chain_list() } //} @@ -352,10 +340,6 @@ impl + IsA> PadExt for O { } } - //fn get_range(&self, offset: u64, size: u32, buffer: /*Ignored*/Buffer) -> FlowReturn { - // unsafe { TODO: call ffi::gst_pad_get_range() } - //} - //fn get_sticky_event(&self, event_type: /*Ignored*/EventType, idx: u32) -> /*Ignored*/Option { // unsafe { TODO: call ffi::gst_pad_get_sticky_event() } //} @@ -506,14 +490,6 @@ impl + IsA> PadExt for O { // unsafe { TODO: call ffi::gst_pad_proxy_query_caps() } //} - //fn pull_range(&self, offset: u64, size: u32, buffer: /*Ignored*/Buffer) -> FlowReturn { - // unsafe { TODO: call ffi::gst_pad_pull_range() } - //} - - //fn push(&self, buffer: /*Ignored*/&mut Buffer) -> FlowReturn { - // unsafe { TODO: call ffi::gst_pad_push() } - //} - //fn push_event(&self, event: /*Ignored*/&mut Event) -> bool { // unsafe { TODO: call ffi::gst_pad_push_event() } //} diff --git a/gstreamer/src/auto/stream.rs b/gstreamer/src/auto/stream.rs index 4171d3eb8..32d95c1a8 100644 --- a/gstreamer/src/auto/stream.rs +++ b/gstreamer/src/auto/stream.rs @@ -6,6 +6,8 @@ use Caps; use Object; use StreamFlags; use StreamType; +#[cfg(feature = "v1_10")] +use TagList; use ffi; use glib; use glib::Value; @@ -55,8 +57,8 @@ pub trait StreamExt { #[cfg(feature = "v1_10")] fn get_stream_type(&self) -> StreamType; - //#[cfg(feature = "v1_10")] - //fn get_tags(&self) -> /*Ignored*/Option; + #[cfg(feature = "v1_10")] + fn get_tags(&self) -> Option; #[cfg(feature = "v1_10")] fn set_caps<'a, P: Into>>(&self, caps: P); @@ -67,8 +69,8 @@ pub trait StreamExt { #[cfg(feature = "v1_10")] fn set_stream_type(&self, stream_type: StreamType); - //#[cfg(feature = "v1_10")] - //fn set_tags<'a, P: Into>>(&self, tags: P); + #[cfg(feature = "v1_10")] + fn set_tags<'a, P: Into>>(&self, tags: P); fn get_property_stream_flags(&self) -> StreamFlags; @@ -79,10 +81,6 @@ pub trait StreamExt { fn get_property_stream_type(&self) -> StreamType; fn set_property_stream_type(&self, stream_type: StreamType); - - //fn get_property_tags(&self) -> /*Ignored*/Option; - - //fn set_property_tags(&self, tags: /*Ignored*/Option<&TagList>); } impl + IsA> StreamExt for O { @@ -114,10 +112,12 @@ impl + IsA> StreamExt for O { } } - //#[cfg(feature = "v1_10")] - //fn get_tags(&self) -> /*Ignored*/Option { - // unsafe { TODO: call ffi::gst_stream_get_tags() } - //} + #[cfg(feature = "v1_10")] + fn get_tags(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_stream_get_tags(self.to_glib_none().0)) + } + } #[cfg(feature = "v1_10")] fn set_caps<'a, P: Into>>(&self, caps: P) { @@ -142,10 +142,14 @@ impl + IsA> StreamExt for O { } } - //#[cfg(feature = "v1_10")] - //fn set_tags<'a, P: Into>>(&self, tags: P) { - // unsafe { TODO: call ffi::gst_stream_set_tags() } - //} + #[cfg(feature = "v1_10")] + fn set_tags<'a, P: Into>>(&self, tags: P) { + let tags = tags.into(); + let tags = tags.to_glib_none(); + unsafe { + ffi::gst_stream_set_tags(self.to_glib_none().0, tags.0); + } + } fn get_property_stream_flags(&self) -> StreamFlags { let mut value = Value::from(&0u32); @@ -184,18 +188,4 @@ impl + IsA> StreamExt for O { gobject_ffi::g_object_set_property(self.to_glib_none().0, "stream-type".to_glib_none().0, Value::from(&stream_type).to_glib_none().0); } } - - //fn get_property_tags(&self) -> /*Ignored*/Option { - // let mut value = Value::from(None::<&/*Ignored*/TagList>); - // unsafe { - // gobject_ffi::g_object_get_property(self.to_glib_none().0, "tags".to_glib_none().0, value.to_glib_none_mut().0); - // } - // value.get() - //} - - //fn set_property_tags(&self, tags: /*Ignored*/Option<&TagList>) { - // unsafe { - // gobject_ffi::g_object_set_property(self.to_glib_none().0, "tags".to_glib_none().0, Value::from(tags).to_glib_none().0); - // } - //} } diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index df93f5298..af9b506f4 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -10,12 +10,15 @@ use Pad; use PadProbeType; use PadProbeReturn; use Buffer; +use FlowReturn; use std::cell::RefCell; use std::mem::transmute; +use std::ptr; use glib::{IsA, StaticType}; -use glib::translate::{ToGlib, FromGlib, from_glib, from_glib_none, from_glib_borrow}; +use glib::translate::{ToGlib, FromGlib, from_glib, from_glib_none, from_glib_borrow, + from_glib_full}; use glib::source::CallbackGuard; use glib_ffi::gpointer; @@ -62,6 +65,12 @@ pub trait PadExtManual { where F: FnMut(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static; fn remove_probe(&self, id: PadProbeId); + + fn chain(&self, buffer: Buffer) -> FlowReturn; + fn push(&self, buffer: Buffer) -> FlowReturn; + + fn pull_range(&self, offset: u64, size: u32) -> Result; + fn get_range(&self, offset: u64, size: u32) -> Result; } impl> PadExtManual for O { @@ -87,6 +96,48 @@ impl> PadExtManual for O { ffi::gst_pad_remove_probe(self.to_glib_none().0, id.to_glib()); } } + + fn chain(&self, buffer: Buffer) -> FlowReturn { + unsafe { from_glib(ffi::gst_pad_chain(self.to_glib_none().0, buffer.into_ptr())) } + } + + fn push(&self, buffer: Buffer) -> FlowReturn { + unsafe { from_glib(ffi::gst_pad_push(self.to_glib_none().0, buffer.into_ptr())) } + } + + fn get_range(&self, offset: u64, size: u32) -> Result { + unsafe { + let mut buffer = ptr::null_mut(); + let ret = from_glib(ffi::gst_pad_get_range( + self.to_glib_none().0, + offset, + size, + &mut buffer, + )); + if ret == FlowReturn::Ok { + Ok(from_glib_full(buffer)) + } else { + Err(ret) + } + } + } + + fn pull_range(&self, offset: u64, size: u32) -> Result { + unsafe { + let mut buffer = ptr::null_mut(); + let ret = from_glib(ffi::gst_pad_pull_range( + self.to_glib_none().0, + offset, + size, + &mut buffer, + )); + if ret == FlowReturn::Ok { + Ok(from_glib_full(buffer)) + } else { + Err(ret) + } + } + } } unsafe extern "C" fn trampoline_pad_probe(