mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
Add ChildProxy bindings
This commit is contained in:
parent
02a4c8c14d
commit
9d35eff8d5
9 changed files with 220 additions and 11 deletions
|
@ -55,11 +55,13 @@ generate = [
|
|||
"Gst.PadMode",
|
||||
"Gst.SchedulingFlags",
|
||||
"Gst.IteratorResult",
|
||||
"Gst.ChildProxy",
|
||||
]
|
||||
|
||||
manual = [
|
||||
"GLib.Error",
|
||||
"GLib.Source",
|
||||
"GObject.Object",
|
||||
"Gst.Structure",
|
||||
"Gst.Iterator",
|
||||
]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// This file was generated by gir (a01311c+) from gir-files (???)
|
||||
// DO NOT EDIT
|
||||
|
||||
use ChildProxy;
|
||||
use Element;
|
||||
use Iterator;
|
||||
use Object;
|
||||
|
@ -21,7 +22,7 @@ use std::mem::transmute;
|
|||
use std::ptr;
|
||||
|
||||
glib_wrapper! {
|
||||
pub struct Bin(Object<ffi::GstBin>): Element, Object;
|
||||
pub struct Bin(Object<ffi::GstBin>): Element, Object, ChildProxy;
|
||||
|
||||
match fn {
|
||||
get_type => || ffi::gst_bin_get_type(),
|
||||
|
|
147
gstreamer/src/auto/child_proxy.rs
Normal file
147
gstreamer/src/auto/child_proxy.rs
Normal file
|
@ -0,0 +1,147 @@
|
|||
// This file was generated by gir (a01311c+) from gir-files (???)
|
||||
// DO NOT EDIT
|
||||
|
||||
use ffi;
|
||||
use glib;
|
||||
use glib::object::Downcast;
|
||||
use glib::object::IsA;
|
||||
use glib::signal::connect;
|
||||
use glib::translate::*;
|
||||
use glib_ffi;
|
||||
use gobject_ffi;
|
||||
use libc;
|
||||
use std::boxed::Box as Box_;
|
||||
use std::mem;
|
||||
use std::mem::transmute;
|
||||
use std::ptr;
|
||||
|
||||
glib_wrapper! {
|
||||
pub struct ChildProxy(Object<ffi::GstChildProxy>);
|
||||
|
||||
match fn {
|
||||
get_type => || ffi::gst_child_proxy_get_type(),
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for ChildProxy {}
|
||||
unsafe impl Sync for ChildProxy {}
|
||||
|
||||
pub trait ChildProxyExt {
|
||||
fn child_added<P: IsA<glib::Object>>(&self, child: &P, name: &str);
|
||||
|
||||
fn child_removed<P: IsA<glib::Object>>(&self, child: &P, name: &str);
|
||||
|
||||
//fn get(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
|
||||
|
||||
fn get_child_by_index(&self, index: u32) -> Option<glib::Object>;
|
||||
|
||||
fn get_child_by_name(&self, name: &str) -> Option<glib::Object>;
|
||||
|
||||
fn get_children_count(&self) -> u32;
|
||||
|
||||
//fn get_property(&self, name: &str, value: /*Ignored*/glib::Value);
|
||||
|
||||
//fn get_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported);
|
||||
|
||||
//fn lookup(&self, name: &str, pspec: /*Ignored*/glib::ParamSpec) -> Option<glib::Object>;
|
||||
|
||||
//fn set(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs);
|
||||
|
||||
//fn set_property(&self, name: &str, value: /*Ignored*/&glib::Value);
|
||||
|
||||
//fn set_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported);
|
||||
|
||||
fn connect_child_added<F: Fn(&Self, &glib::Object, &str) + Send + Sync + 'static>(&self, f: F) -> u64;
|
||||
|
||||
fn connect_child_removed<F: Fn(&Self, &glib::Object, &str) + Send + Sync + 'static>(&self, f: F) -> u64;
|
||||
}
|
||||
|
||||
impl<O: IsA<ChildProxy> + IsA<glib::object::Object>> ChildProxyExt for O {
|
||||
fn child_added<P: IsA<glib::Object>>(&self, child: &P, name: &str) {
|
||||
unsafe {
|
||||
ffi::gst_child_proxy_child_added(self.to_glib_none().0, child.to_glib_none().0, name.to_glib_none().0);
|
||||
}
|
||||
}
|
||||
|
||||
fn child_removed<P: IsA<glib::Object>>(&self, child: &P, name: &str) {
|
||||
unsafe {
|
||||
ffi::gst_child_proxy_child_removed(self.to_glib_none().0, child.to_glib_none().0, name.to_glib_none().0);
|
||||
}
|
||||
}
|
||||
|
||||
//fn get(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
|
||||
// unsafe { TODO: call ffi::gst_child_proxy_get() }
|
||||
//}
|
||||
|
||||
fn get_child_by_index(&self, index: u32) -> Option<glib::Object> {
|
||||
unsafe {
|
||||
from_glib_full(ffi::gst_child_proxy_get_child_by_index(self.to_glib_none().0, index))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_child_by_name(&self, name: &str) -> Option<glib::Object> {
|
||||
unsafe {
|
||||
from_glib_full(ffi::gst_child_proxy_get_child_by_name(self.to_glib_none().0, name.to_glib_none().0))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_children_count(&self) -> u32 {
|
||||
unsafe {
|
||||
ffi::gst_child_proxy_get_children_count(self.to_glib_none().0)
|
||||
}
|
||||
}
|
||||
|
||||
//fn get_property(&self, name: &str, value: /*Ignored*/glib::Value) {
|
||||
// unsafe { TODO: call ffi::gst_child_proxy_get_property() }
|
||||
//}
|
||||
|
||||
//fn get_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
|
||||
// unsafe { TODO: call ffi::gst_child_proxy_get_valist() }
|
||||
//}
|
||||
|
||||
//fn lookup(&self, name: &str, pspec: /*Ignored*/glib::ParamSpec) -> Option<glib::Object> {
|
||||
// unsafe { TODO: call ffi::gst_child_proxy_lookup() }
|
||||
//}
|
||||
|
||||
//fn set(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
|
||||
// unsafe { TODO: call ffi::gst_child_proxy_set() }
|
||||
//}
|
||||
|
||||
//fn set_property(&self, name: &str, value: /*Ignored*/&glib::Value) {
|
||||
// unsafe { TODO: call ffi::gst_child_proxy_set_property() }
|
||||
//}
|
||||
|
||||
//fn set_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
|
||||
// unsafe { TODO: call ffi::gst_child_proxy_set_valist() }
|
||||
//}
|
||||
|
||||
fn connect_child_added<F: Fn(&Self, &glib::Object, &str) + Send + Sync + 'static>(&self, f: F) -> u64 {
|
||||
unsafe {
|
||||
let f: Box_<Box_<Fn(&Self, &glib::Object, &str) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
|
||||
connect(self.to_glib_none().0, "child-added",
|
||||
transmute(child_added_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
|
||||
}
|
||||
}
|
||||
|
||||
fn connect_child_removed<F: Fn(&Self, &glib::Object, &str) + Send + Sync + 'static>(&self, f: F) -> u64 {
|
||||
unsafe {
|
||||
let f: Box_<Box_<Fn(&Self, &glib::Object, &str) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
|
||||
connect(self.to_glib_none().0, "child-removed",
|
||||
transmute(child_removed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn child_added_trampoline<P>(this: *mut ffi::GstChildProxy, object: *mut gobject_ffi::GObject, name: *mut libc::c_char, f: glib_ffi::gpointer)
|
||||
where P: IsA<ChildProxy> {
|
||||
callback_guard!();
|
||||
let f: &Box_<Fn(&P, &glib::Object, &str) + Send + Sync + 'static> = transmute(f);
|
||||
f(&ChildProxy::from_glib_none(this).downcast_unchecked(), &from_glib_none(object), &String::from_glib_none(name))
|
||||
}
|
||||
|
||||
unsafe extern "C" fn child_removed_trampoline<P>(this: *mut ffi::GstChildProxy, object: *mut gobject_ffi::GObject, name: *mut libc::c_char, f: glib_ffi::gpointer)
|
||||
where P: IsA<ChildProxy> {
|
||||
callback_guard!();
|
||||
let f: &Box_<Fn(&P, &glib::Object, &str) + Send + Sync + 'static> = transmute(f);
|
||||
f(&ChildProxy::from_glib_none(this).downcast_unchecked(), &from_glib_none(object), &String::from_glib_none(name))
|
||||
}
|
|
@ -9,6 +9,7 @@ use FlowReturn;
|
|||
use Plugin;
|
||||
use ffi;
|
||||
use glib;
|
||||
use glib::object::IsA;
|
||||
use glib::translate::*;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
@ -89,15 +90,15 @@ pub fn debug_is_colored() -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
//pub fn debug_log<'a, P: IsA</*Ignored*/glib::Object> + 'a, Q: Into<Option<&'a P>>>(category: /*Ignored*/&mut DebugCategory, level: /*Ignored*/DebugLevel, file: &str, function: &str, line: i32, object: Q, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
|
||||
//pub fn debug_log<'a, P: IsA<glib::Object> + 'a, Q: Into<Option<&'a P>>>(category: /*Ignored*/&mut DebugCategory, level: /*Ignored*/DebugLevel, file: &str, function: &str, line: i32, object: Q, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
|
||||
// unsafe { TODO: call ffi::gst_debug_log() }
|
||||
//}
|
||||
|
||||
//pub fn debug_log_default<'a, P: IsA</*Ignored*/glib::Object> + 'a, Q: Into<Option<&'a P>>, R: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(category: /*Ignored*/&mut DebugCategory, level: /*Ignored*/DebugLevel, file: &str, function: &str, line: i32, object: Q, message: /*Ignored*/&mut DebugMessage, user_data: R) {
|
||||
//pub fn debug_log_default<'a, P: IsA<glib::Object> + 'a, Q: Into<Option<&'a P>>, R: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(category: /*Ignored*/&mut DebugCategory, level: /*Ignored*/DebugLevel, file: &str, function: &str, line: i32, object: Q, message: /*Ignored*/&mut DebugMessage, user_data: R) {
|
||||
// unsafe { TODO: call ffi::gst_debug_log_default() }
|
||||
//}
|
||||
|
||||
//pub fn debug_log_valist<'a, P: IsA</*Ignored*/glib::Object> + 'a, Q: Into<Option<&'a P>>>(category: /*Ignored*/&mut DebugCategory, level: /*Ignored*/DebugLevel, file: &str, function: &str, line: i32, object: Q, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
|
||||
//pub fn debug_log_valist<'a, P: IsA<glib::Object> + 'a, Q: Into<Option<&'a P>>>(category: /*Ignored*/&mut DebugCategory, level: /*Ignored*/DebugLevel, file: &str, function: &str, line: i32, object: Q, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
|
||||
// unsafe { TODO: call ffi::gst_debug_log_valist() }
|
||||
//}
|
||||
|
||||
|
@ -480,7 +481,7 @@ pub fn util_gdouble_to_guint64(value: f64) -> u64 {
|
|||
}
|
||||
|
||||
//#[cfg(feature = "v1_12")]
|
||||
//pub fn util_get_object_array<P: IsA</*Ignored*/glib::Object>>(object: &P, name: &str, array: /*Ignored*/glib::ValueArray) -> bool {
|
||||
//pub fn util_get_object_array<P: IsA<glib::Object>>(object: &P, name: &str, array: /*Ignored*/glib::ValueArray) -> bool {
|
||||
// unsafe { TODO: call ffi::gst_util_get_object_array() }
|
||||
//}
|
||||
|
||||
|
@ -533,12 +534,15 @@ pub fn util_seqnum_next() -> u32 {
|
|||
}
|
||||
}
|
||||
|
||||
//pub fn util_set_object_arg<P: IsA</*Ignored*/glib::Object>>(object: &P, name: &str, value: &str) {
|
||||
// unsafe { TODO: call ffi::gst_util_set_object_arg() }
|
||||
//}
|
||||
pub fn util_set_object_arg<P: IsA<glib::Object>>(object: &P, name: &str, value: &str) {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
ffi::gst_util_set_object_arg(object.to_glib_none().0, name.to_glib_none().0, value.to_glib_none().0);
|
||||
}
|
||||
}
|
||||
|
||||
//#[cfg(feature = "v1_12")]
|
||||
//pub fn util_set_object_array<P: IsA</*Ignored*/glib::Object>>(object: &P, name: &str, array: /*Ignored*/&glib::ValueArray) -> bool {
|
||||
//pub fn util_set_object_array<P: IsA<glib::Object>>(object: &P, name: &str, array: /*Ignored*/&glib::ValueArray) -> bool {
|
||||
// unsafe { TODO: call ffi::gst_util_set_object_array() }
|
||||
//}
|
||||
|
||||
|
|
|
@ -8,6 +8,10 @@ pub use self::bin::BinExt;
|
|||
mod bus;
|
||||
pub use self::bus::Bus;
|
||||
|
||||
mod child_proxy;
|
||||
pub use self::child_proxy::ChildProxy;
|
||||
pub use self::child_proxy::ChildProxyExt;
|
||||
|
||||
mod clock;
|
||||
pub use self::clock::Clock;
|
||||
pub use self::clock::ClockExt;
|
||||
|
@ -196,6 +200,7 @@ pub mod functions;
|
|||
#[doc(hidden)]
|
||||
pub mod traits {
|
||||
pub use super::BinExt;
|
||||
pub use super::ChildProxyExt;
|
||||
pub use super::ClockExt;
|
||||
pub use super::DeviceExt;
|
||||
pub use super::DeviceMonitorExt;
|
||||
|
|
|
@ -28,7 +28,7 @@ impl Object {
|
|||
}
|
||||
}
|
||||
|
||||
//pub fn default_deep_notify<P: IsA</*Ignored*/glib::Object>, Q: IsA<Object>, R: IsA</*Ignored*/glib::ParamSpec>>(object: &P, orig: &Q, pspec: &R, excluded_props: &[&str]) {
|
||||
//pub fn default_deep_notify<P: IsA<glib::Object>, Q: IsA<Object>, R: IsA</*Ignored*/glib::ParamSpec>>(object: &P, orig: &Q, pspec: &R, excluded_props: &[&str]) {
|
||||
// unsafe { TODO: call ffi::gst_object_default_deep_notify() }
|
||||
//}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// DO NOT EDIT
|
||||
|
||||
use Bin;
|
||||
use ChildProxy;
|
||||
use Clock;
|
||||
use ClockTime;
|
||||
use Element;
|
||||
|
@ -16,7 +17,7 @@ use std::mem;
|
|||
use std::ptr;
|
||||
|
||||
glib_wrapper! {
|
||||
pub struct Pipeline(Object<ffi::GstPipeline>): Bin, Element, Object;
|
||||
pub struct Pipeline(Object<ffi::GstPipeline>): Bin, Element, Object, ChildProxy;
|
||||
|
||||
match fn {
|
||||
get_type => || ffi::gst_pipeline_get_type(),
|
||||
|
|
47
gstreamer/src/child_proxy.rs
Normal file
47
gstreamer/src/child_proxy.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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;
|
||||
use glib::object::IsA;
|
||||
use glib::translate::*;
|
||||
use std::ptr;
|
||||
use ChildProxy;
|
||||
|
||||
pub trait ChildProxyExtManual {
|
||||
fn get_property(&self, name: &str) -> Option<glib::Value>;
|
||||
fn set_property(&self, name: &str, value: &glib::Value) -> Result<(), glib::BoolError>;
|
||||
}
|
||||
|
||||
impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {
|
||||
fn get_property(&self, name: &str) -> Option<glib::Value> {
|
||||
unsafe {
|
||||
let found: bool = from_glib(ffi::gst_child_proxy_lookup(self.to_glib_none().0, name.to_glib_none().0, ptr::null_mut(), ptr::null_mut()));
|
||||
if !found {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut value = glib::Value::uninitialized();
|
||||
ffi::gst_child_proxy_get_property(self.to_glib_none().0, name.to_glib_none().0, value.to_glib_none_mut().0);
|
||||
Some(value)
|
||||
}
|
||||
}
|
||||
|
||||
fn set_property(&self, name: &str, value: &glib::Value) -> Result<(), glib::BoolError> {
|
||||
unsafe {
|
||||
let found: bool = from_glib(ffi::gst_child_proxy_lookup(self.to_glib_none().0, name.to_glib_none().0, ptr::null_mut(), ptr::null_mut()));
|
||||
if !found {
|
||||
return Err(glib::BoolError("Child property not found"));
|
||||
}
|
||||
|
||||
ffi::gst_child_proxy_set_property(self.to_glib_none().0, name.to_glib_none().0, value.to_glib_none().0);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
|
@ -73,10 +73,12 @@ mod gobject;
|
|||
mod segment;
|
||||
mod proxy_pad;
|
||||
mod ghost_pad;
|
||||
mod child_proxy;
|
||||
pub use element::ElementExtManual;
|
||||
pub use bin::BinExtManual;
|
||||
pub use pad::{PadExtManual, PadProbeId, PadProbeInfo, PadProbeData, PAD_PROBE_ID_INVALID};
|
||||
pub use gobject::GObjectExtManualGst;
|
||||
pub use child_proxy::ChildProxyExtManual;
|
||||
mod iterator;
|
||||
pub use self::iterator::Iterator;
|
||||
|
||||
|
|
Loading…
Reference in a new issue