From 52dbf03d4fe939882e9e0e8e75f791dd7303321f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 29 Jul 2017 14:04:34 +0100 Subject: [PATCH] Add functions using queries --- Gir_Gst.toml | 35 +++++++++++++++++++++++++++++ gstreamer/src/auto/element.rs | 6 ----- gstreamer/src/auto/pad.rs | 30 ------------------------- gstreamer/src/element.rs | 14 ++++++++++++ gstreamer/src/lib.rs | 1 + gstreamer/src/pad.rs | 42 ++++++++++++++++++++++++++++++++++- 6 files changed, 91 insertions(+), 37 deletions(-) diff --git a/Gir_Gst.toml b/Gir_Gst.toml index 4adf5f931..3fb1e5d30 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -132,6 +132,11 @@ name = "Gst.TagList" status = "manual" ref_mode = "ref" +[[object]] +name = "Gst.Query" +status = "manual" +ref_mode = "ref" + [[object]] name = "Gst.Clock" status = "generate" @@ -198,6 +203,11 @@ status = "generate" [object.function.return] bool_return_is_error = "Failed to sync state with parent" + [[object.function]] + name = "query" + # correct mutability + ignore = true + [[object]] name = "Gst.ElementFactory" status = "generate" @@ -331,6 +341,31 @@ status = "generate" # Has getter/setter functions ignore = true + [[object.function]] + name = "query" + # Correct mutability + ignore = true + + [[object.function]] + name = "peer_query" + # Correct mutability + ignore = true + + [[object.function]] + name = "query_default" + # Correct mutability + ignore = true + + [[object.function]] + name = "proxy_query_caps" + # Correct mutability + ignore = true + + [[object.function]] + name = "proxy_query_accept_caps" + # Correct mutability + ignore = true + [[object]] name = "Gst.Stream" status = "generate" diff --git a/gstreamer/src/auto/element.rs b/gstreamer/src/auto/element.rs index 2dfefe5f9..b9687de52 100644 --- a/gstreamer/src/auto/element.rs +++ b/gstreamer/src/auto/element.rs @@ -160,8 +160,6 @@ pub trait ElementExt { fn provide_clock(&self) -> Option; - //fn query(&self, query: /*Ignored*/&mut Query) -> bool; - fn query_convert(&self, src_format: Format, src_val: i64, dest_format: Format) -> Option; fn query_duration(&self, format: Format) -> Option; @@ -438,10 +436,6 @@ impl + IsA> ElementExt for O { } } - //fn query(&self, query: /*Ignored*/&mut Query) -> bool { - // unsafe { TODO: call ffi::gst_element_query() } - //} - fn query_convert(&self, src_format: Format, src_val: i64, dest_format: Format) -> Option { unsafe { let mut dest_val = mem::uninitialized(); diff --git a/gstreamer/src/auto/pad.rs b/gstreamer/src/auto/pad.rs index 04724d01d..a03af4b92 100644 --- a/gstreamer/src/auto/pad.rs +++ b/gstreamer/src/auto/pad.rs @@ -148,8 +148,6 @@ pub trait PadExt { fn pause_task(&self) -> Result<(), glib::error::BoolError>; - //fn peer_query(&self, query: /*Ignored*/&mut Query) -> bool; - fn peer_query_accept_caps(&self, caps: &Caps) -> bool; fn peer_query_caps<'a, P: Into>>(&self, filter: P) -> Option; @@ -160,24 +158,16 @@ pub trait PadExt { fn peer_query_position(&self, format: Format) -> Option; - //fn proxy_query_accept_caps(&self, query: /*Ignored*/&mut Query) -> bool; - - //fn proxy_query_caps(&self, query: /*Ignored*/&mut Query) -> bool; - //fn push_event(&self, event: /*Ignored*/&mut Event) -> bool; //fn push_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn; - //fn query(&self, query: /*Ignored*/&mut Query) -> bool; - fn query_accept_caps(&self, caps: &Caps) -> bool; fn query_caps<'a, P: Into>>(&self, filter: P) -> Option; fn query_convert(&self, src_format: Format, src_val: i64, dest_format: Format) -> Option; - //fn query_default<'a, P: IsA + 'a, Q: Into>>(&self, parent: Q, query: /*Ignored*/&mut Query) -> bool; - fn query_duration(&self, format: Format) -> Option; fn query_position(&self, format: Format) -> Option; @@ -438,10 +428,6 @@ impl + IsA> PadExt for O { } } - //fn peer_query(&self, query: /*Ignored*/&mut Query) -> bool { - // unsafe { TODO: call ffi::gst_pad_peer_query() } - //} - fn peer_query_accept_caps(&self, caps: &Caps) -> bool { unsafe { from_glib(ffi::gst_pad_peer_query_accept_caps(self.to_glib_none().0, caps.to_glib_none().0)) @@ -480,14 +466,6 @@ impl + IsA> PadExt for O { } } - //fn proxy_query_accept_caps(&self, query: /*Ignored*/&mut Query) -> bool { - // unsafe { TODO: call ffi::gst_pad_proxy_query_accept_caps() } - //} - - //fn proxy_query_caps(&self, query: /*Ignored*/&mut Query) -> bool { - // unsafe { TODO: call ffi::gst_pad_proxy_query_caps() } - //} - //fn push_event(&self, event: /*Ignored*/&mut Event) -> bool { // unsafe { TODO: call ffi::gst_pad_push_event() } //} @@ -496,10 +474,6 @@ impl + IsA> PadExt for O { // unsafe { TODO: call ffi::gst_pad_push_list() } //} - //fn query(&self, query: /*Ignored*/&mut Query) -> bool { - // unsafe { TODO: call ffi::gst_pad_query() } - //} - fn query_accept_caps(&self, caps: &Caps) -> bool { unsafe { from_glib(ffi::gst_pad_query_accept_caps(self.to_glib_none().0, caps.to_glib_none().0)) @@ -522,10 +496,6 @@ impl + IsA> PadExt for O { } } - //fn query_default<'a, P: IsA + 'a, Q: Into>>(&self, parent: Q, query: /*Ignored*/&mut Query) -> bool { - // unsafe { TODO: call ffi::gst_pad_query_default() } - //} - fn query_duration(&self, format: Format) -> Option { unsafe { let mut duration = mem::uninitialized(); diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index d06913e2a..5317912e1 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -11,6 +11,8 @@ use Element; use glib; use glib::IsA; use glib::translate::{ToGlibPtr, from_glib}; +use QueryRef; +use miniobject::MiniObject; use ffi; @@ -39,3 +41,15 @@ impl Element { } } } + +pub trait ElementExtManual { + fn query(&self, query: &mut QueryRef) -> bool; +} + +impl> ElementExtManual for O { + fn query(&self, query: &mut QueryRef) -> bool { + unsafe { + from_glib(ffi::gst_element_query(self.to_glib_none().0, query.as_mut_ptr())) + } + } +} diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index e4bb56734..83aaca921 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -71,6 +71,7 @@ mod bus; mod pad; mod gobject; mod segment; +pub use element::ElementExtManual; pub use bin::BinExtManual; pub use pad::{PadExtManual, PadProbeId, PadProbeInfo, PadProbeData, PAD_PROBE_ID_INVALID}; pub use gobject::GObjectExtManualGst; diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 663ae9acf..c4b45d558 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -12,6 +12,7 @@ use PadProbeReturn; use Buffer; use BufferList; use FlowReturn; +use QueryRef; use miniobject::MiniObject; use std::cell::RefCell; @@ -19,9 +20,10 @@ use std::mem::transmute; use std::ptr; use glib::{IsA, StaticType}; -use glib::translate::{ToGlib, FromGlib, from_glib, from_glib_none, from_glib_full}; +use glib::translate::{ToGlib, ToGlibPtr, FromGlib, from_glib, from_glib_none, from_glib_full}; use glib::source::CallbackGuard; use glib_ffi::gpointer; +use glib::Object; use libc; @@ -72,6 +74,12 @@ pub trait PadExtManual { fn pull_range(&self, offset: u64, size: u32) -> Result; fn get_range(&self, offset: u64, size: u32) -> Result; + + fn peer_query(&self, query: &mut QueryRef) -> bool; + fn query(&self, query: &mut QueryRef) -> bool; + fn query_default<'a, P: IsA + 'a, Q: Into>>(&self, parent: Q, query: &mut QueryRef) -> bool; + fn proxy_query_caps(&self, query: &mut QueryRef) -> bool; + fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool; } impl> PadExtManual for O { @@ -139,6 +147,38 @@ impl> PadExtManual for O { } } } + + fn query(&self, query: &mut QueryRef) -> bool { + unsafe { + from_glib(ffi::gst_pad_query(self.to_glib_none().0, query.as_mut_ptr())) + } + } + + fn peer_query(&self, query: &mut QueryRef) -> bool { + unsafe { + from_glib(ffi::gst_pad_peer_query(self.to_glib_none().0, query.as_mut_ptr())) + } + } + + fn query_default<'a, P: IsA + 'a, Q: Into>>(&self, parent: Q, query: &mut QueryRef) -> bool { + let parent = parent.into(); + let parent = parent.to_glib_none(); + unsafe { + from_glib(ffi::gst_pad_query_default(self.to_glib_none().0, parent.0 as *mut _, query.as_mut_ptr())) + } + } + + fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool { + unsafe { + from_glib(ffi::gst_pad_proxy_query_accept_caps(self.to_glib_none().0, query.as_mut_ptr())) + } + } + + fn proxy_query_caps(&self, query: &mut QueryRef) -> bool { + unsafe { + from_glib(ffi::gst_pad_proxy_query_accept_caps(self.to_glib_none().0, query.as_mut_ptr())) + } + } } unsafe extern "C" fn trampoline_pad_probe(