From 917255de89a3aef7a2e496c08ddc002bd820dd5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 18 Dec 2017 10:05:42 +0200 Subject: [PATCH] Add typefind helper bindings --- Gir_GstBase.toml | 10 +++++++ gstreamer-base/src/auto/functions.rs | 40 ++++++++++++++++++++++++++++ gstreamer-base/src/auto/mod.rs | 2 ++ gstreamer-base/src/functions.rs | 39 +++++++++++++++++++++++++++ gstreamer-base/src/lib.rs | 4 +++ 5 files changed, 95 insertions(+) create mode 100644 gstreamer-base/src/auto/functions.rs create mode 100644 gstreamer-base/src/functions.rs diff --git a/Gir_GstBase.toml b/Gir_GstBase.toml index 359f06d3b..ee5bc128a 100644 --- a/Gir_GstBase.toml +++ b/Gir_GstBase.toml @@ -31,6 +31,7 @@ manual = [ "Gst.FlowReturn", "Gst.Format", "Gst.Pad", + "Gst.TypeFindProbability", ] [[object]] @@ -71,6 +72,15 @@ status = "manual" trait = false concurrency = "none" +[[object]] +name = "GstBase.*" +status = "generate" + + [[object.function]] + name = "type_find_helper_for_data" + # broken data type + ignore = true + [[object]] name = "Gst.Structure" status = "manual" diff --git a/gstreamer-base/src/auto/functions.rs b/gstreamer-base/src/auto/functions.rs new file mode 100644 index 000000000..91c1886cf --- /dev/null +++ b/gstreamer-base/src/auto/functions.rs @@ -0,0 +1,40 @@ +// This file was generated by gir (d50d839) from gir-files (???) +// DO NOT EDIT + +use ffi; +use glib::object::IsA; +use glib::translate::*; +use gst; +use std::mem; + + +pub fn type_find_helper>(src: &P, size: u64) -> Option { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gst_type_find_helper(src.to_glib_none().0, size)) + } +} + +pub fn type_find_helper_for_buffer<'a, P: IsA + 'a, Q: Into>>(obj: Q, buf: &gst::Buffer) -> (Option, gst::TypeFindProbability) { + assert_initialized_main_thread!(); + let obj = obj.into(); + let obj = obj.to_glib_none(); + unsafe { + let mut prob = mem::uninitialized(); + let ret = from_glib_full(ffi::gst_type_find_helper_for_buffer(obj.0, buf.to_glib_none().0, &mut prob)); + (ret, from_glib(prob)) + } +} + +pub fn type_find_helper_for_extension<'a, P: IsA + 'a, Q: Into>>(obj: Q, extension: &str) -> Option { + assert_initialized_main_thread!(); + let obj = obj.into(); + let obj = obj.to_glib_none(); + unsafe { + from_glib_full(ffi::gst_type_find_helper_for_extension(obj.0, extension.to_glib_none().0)) + } +} + +//pub fn type_find_helper_get_range<'a, P: IsA, Q: IsA + 'a, R: Into>>(obj: &P, parent: R, func: /*Unknown conversion*//*Unimplemented*/TypeFindHelperGetRangeFunction, size: u64, extension: &str) -> (Option, gst::TypeFindProbability) { +// unsafe { TODO: call ffi::gst_type_find_helper_get_range() } +//} diff --git a/gstreamer-base/src/auto/mod.rs b/gstreamer-base/src/auto/mod.rs index d1e4058a1..365c498f6 100644 --- a/gstreamer-base/src/auto/mod.rs +++ b/gstreamer-base/src/auto/mod.rs @@ -19,6 +19,8 @@ pub use self::base_transform::BaseTransformExt; mod push_src; pub use self::push_src::PushSrc; +pub mod functions; + #[doc(hidden)] pub mod traits { pub use super::BaseSinkExt; diff --git a/gstreamer-base/src/functions.rs b/gstreamer-base/src/functions.rs new file mode 100644 index 000000000..600a7882c --- /dev/null +++ b/gstreamer-base/src/functions.rs @@ -0,0 +1,39 @@ +// 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 ffi; +use glib::object::IsA; +use glib::translate::*; +use gst; +use std::mem; + +pub fn type_find_helper_for_data< + 'a, + P: IsA + 'a, + Q: Into>, + R: AsRef<[u8]>, +>( + obj: Q, + data: R, +) -> (Option, gst::TypeFindProbability) { + assert_initialized_main_thread!(); + let obj = obj.into(); + let obj = obj.to_glib_none(); + unsafe { + let mut prob = mem::uninitialized(); + let data = data.as_ref(); + let (ptr, len) = (data.as_ptr(), data.len()); + let ret = from_glib_full(ffi::gst_type_find_helper_for_data( + obj.0, + ptr, + len, + &mut prob, + )); + (ret, from_glib(prob)) + } +} diff --git a/gstreamer-base/src/lib.rs b/gstreamer-base/src/lib.rs index 9cae4e17e..5e0318392 100644 --- a/gstreamer-base/src/lib.rs +++ b/gstreamer-base/src/lib.rs @@ -37,6 +37,10 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] mod auto; pub use auto::*; +pub use auto::functions::*; + +pub mod functions; +pub use functions::*; mod adapter; mod flow_combiner;