From 9fdf422e9b81d1de5870d8a2f4d12cad6b30e50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 25 Jul 2017 01:17:50 +0300 Subject: [PATCH] Random cleanup --- gstreamer/src/lib.rs | 9 ++++----- gstreamer/src/pad.rs | 22 +++++++++++++++++++--- gstreamer/src/value.rs | 12 ++---------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 1fffa7ab1..51c5a1fbc 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -49,12 +49,11 @@ pub use auto::traits::ObjectExt as GstObjectExt; pub mod miniobject; pub use miniobject::GstRc; pub mod message; -pub use message::Message; -pub use message::MessageView; +pub use message::{Message, MessageRef, MessageView}; pub mod structure; -pub use structure::Structure; +pub use structure::{Structure, StructureRef}; pub mod caps; -pub use caps::Caps; +pub use caps::{Caps, CapsRef}; pub mod tags; pub use tags::*; @@ -64,7 +63,7 @@ mod bus; mod pad; mod gobject; pub use bin::BinExtManual; -pub use pad::PadExtManual; +pub use pad::{PadExtManual, PadProbeId, PadProbeInfo, PadProbeData, PAD_PROBE_ID_INVALID}; pub use gobject::GObjectExtManualGst; mod value; diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 31d4a5751..11e98be49 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -14,7 +14,7 @@ use std::cell::RefCell; use std::mem::transmute; use glib::IsA; -use glib::translate::{ToGlib, from_glib, from_glib_none}; +use glib::translate::{ToGlib, FromGlib, from_glib, from_glib_none}; use glib::source::CallbackGuard; use glib_ffi::gpointer; @@ -22,7 +22,23 @@ use libc; use ffi; +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] pub struct PadProbeId(libc::c_ulong); +pub const PAD_PROBE_ID_INVALID: PadProbeId = PadProbeId(0); + +impl ToGlib for PadProbeId { + type GlibType = libc::c_ulong; + + fn to_glib(&self) -> libc::c_ulong { + self.0 + } +} + +impl FromGlib for PadProbeId { + fn from_glib(val: libc::c_ulong) -> PadProbeId { + PadProbeId(val) + } +} pub struct PadProbeInfo { pub mask: PadProbeType, @@ -61,13 +77,13 @@ impl> PadExtManual for O { Some(destroy_closure_pad_probe), ); - PadProbeId(id) + from_glib(id) } } fn remove_probe(&self, id: PadProbeId) { unsafe { - ffi::gst_pad_remove_probe(self.to_glib_none().0, id.0 as libc::c_ulong); + ffi::gst_pad_remove_probe(self.to_glib_none().0, id.to_glib()); } } } diff --git a/gstreamer/src/value.rs b/gstreamer/src/value.rs index c270524a0..9a49f0cf1 100644 --- a/gstreamer/src/value.rs +++ b/gstreamer/src/value.rs @@ -204,13 +204,5 @@ impl SetValue for Fraction { } } -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_simple() { - let f: Fraction = (1, 2).into(); - println!("{}", f * 2); - } -} +// TODO: Array, List, Ranges +// GStreamer value operations