Add typefind helper bindings

This commit is contained in:
Sebastian Dröge 2017-12-18 10:05:42 +02:00
parent 12ee7358e3
commit 917255de89
5 changed files with 95 additions and 0 deletions

View file

@ -31,6 +31,7 @@ manual = [
"Gst.FlowReturn", "Gst.FlowReturn",
"Gst.Format", "Gst.Format",
"Gst.Pad", "Gst.Pad",
"Gst.TypeFindProbability",
] ]
[[object]] [[object]]
@ -71,6 +72,15 @@ status = "manual"
trait = false trait = false
concurrency = "none" concurrency = "none"
[[object]]
name = "GstBase.*"
status = "generate"
[[object.function]]
name = "type_find_helper_for_data"
# broken data type
ignore = true
[[object]] [[object]]
name = "Gst.Structure" name = "Gst.Structure"
status = "manual" status = "manual"

View file

@ -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<P: IsA<gst::Pad>>(src: &P, size: u64) -> Option<gst::Caps> {
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<gst::Object> + 'a, Q: Into<Option<&'a P>>>(obj: Q, buf: &gst::Buffer) -> (Option<gst::Caps>, 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<gst::Object> + 'a, Q: Into<Option<&'a P>>>(obj: Q, extension: &str) -> Option<gst::Caps> {
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<gst::Object>, Q: IsA<gst::Object> + 'a, R: Into<Option<&'a Q>>>(obj: &P, parent: R, func: /*Unknown conversion*//*Unimplemented*/TypeFindHelperGetRangeFunction, size: u64, extension: &str) -> (Option<gst::Caps>, gst::TypeFindProbability) {
// unsafe { TODO: call ffi::gst_type_find_helper_get_range() }
//}

View file

@ -19,6 +19,8 @@ pub use self::base_transform::BaseTransformExt;
mod push_src; mod push_src;
pub use self::push_src::PushSrc; pub use self::push_src::PushSrc;
pub mod functions;
#[doc(hidden)] #[doc(hidden)]
pub mod traits { pub mod traits {
pub use super::BaseSinkExt; pub use super::BaseSinkExt;

View file

@ -0,0 +1,39 @@
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<gst::Object> + 'a,
Q: Into<Option<&'a P>>,
R: AsRef<[u8]>,
>(
obj: Q,
data: R,
) -> (Option<gst::Caps>, 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))
}
}

View file

@ -37,6 +37,10 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
mod auto; mod auto;
pub use auto::*; pub use auto::*;
pub use auto::functions::*;
pub mod functions;
pub use functions::*;
mod adapter; mod adapter;
mod flow_combiner; mod flow_combiner;