gstreamer-rs/gstreamer/src/auto/object.rs

357 lines
11 KiB
Rust
Raw Normal View History

2018-04-23 17:34:22 +00:00
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT
use crate::{ClockTime, ControlBinding};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, fmt, mem::transmute};
2020-12-17 22:34:53 +00:00
glib::wrapper! {
#[doc(alias = "GstObject")]
2020-11-21 13:46:33 +00:00
pub struct Object(Object<ffi::GstObject, ffi::GstObjectClass>);
match fn {
type_ => || ffi::gst_object_get_type(),
}
}
impl Object {
2021-11-16 14:02:58 +00:00
pub const NONE: Option<&'static Object> = None;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_check_uniqueness")]
pub fn check_uniqueness(list: &[Object], name: &str) -> bool {
assert_initialized_main_thread!();
unsafe {
2020-11-21 13:46:33 +00:00
from_glib(ffi::gst_object_check_uniqueness(
list.to_glib_none().0,
name.to_glib_none().0,
))
}
}
2020-12-08 13:00:17 +00:00
//#[doc(alias = "gst_object_default_deep_notify")]
//pub fn default_deep_notify(object: &impl IsA<glib::Object>, orig: &impl IsA<Object>, pspec: /*Ignored*/&glib::ParamSpec, excluded_props: &[&str]) {
2020-11-21 13:46:33 +00:00
// unsafe { TODO: call ffi:gst_object_default_deep_notify() }
//}
2020-12-08 13:00:17 +00:00
//#[doc(alias = "gst_object_replace")]
//pub fn replace(oldobj: Option<impl IsA<Object>>, newobj: Option<&impl IsA<Object>>) -> bool {
2020-11-21 13:46:33 +00:00
// unsafe { TODO: call ffi:gst_object_replace() }
//}
}
impl fmt::Display for Object {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2021-04-11 19:38:18 +00:00
f.write_str(&GstObjectExt::name(self))
}
}
unsafe impl Send for Object {}
unsafe impl Sync for Object {}
pub trait GstObjectExt: 'static {
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_add_control_binding")]
fn add_control_binding(
2020-06-09 01:06:49 +00:00
&self,
binding: &impl IsA<ControlBinding>,
2020-06-09 01:06:49 +00:00
) -> Result<(), glib::error::BoolError>;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_default_error")]
2019-11-10 16:55:02 +00:00
fn default_error(&self, error: &glib::Error, debug: Option<&str>);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_get_control_binding")]
#[doc(alias = "get_control_binding")]
2021-04-19 20:13:58 +00:00
fn control_binding(&self, property_name: &str) -> Option<ControlBinding>;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_get_control_rate")]
#[doc(alias = "get_control_rate")]
fn control_rate(&self) -> Option<ClockTime>;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_get_name")]
#[doc(alias = "get_name")]
2021-04-11 19:38:18 +00:00
fn name(&self) -> glib::GString;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_get_parent")]
#[doc(alias = "get_parent")]
#[must_use]
2021-04-11 19:38:18 +00:00
fn parent(&self) -> Option<Object>;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_get_path_string")]
#[doc(alias = "get_path_string")]
2021-04-11 19:38:18 +00:00
fn path_string(&self) -> glib::GString;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_get_value")]
#[doc(alias = "get_value")]
fn value(
&self,
property_name: &str,
timestamp: impl Into<Option<ClockTime>>,
) -> Option<glib::Value>;
2020-12-08 13:00:17 +00:00
//#[doc(alias = "gst_object_get_value_array")]
//#[doc(alias = "get_value_array")]
//fn is_value_array(&self, property_name: &str, timestamp: impl Into<Option<ClockTime>>, interval: impl Into<Option<ClockTime>>, values: /*Unimplemented*/&[&Basic: Pointer]) -> bool;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_has_active_control_bindings")]
fn has_active_control_bindings(&self) -> bool;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_has_ancestor")]
fn has_ancestor(&self, ancestor: &impl IsA<Object>) -> bool;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_has_as_ancestor")]
fn has_as_ancestor(&self, ancestor: &impl IsA<Object>) -> bool;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_has_as_parent")]
fn has_as_parent(&self, parent: &impl IsA<Object>) -> bool;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_remove_control_binding")]
fn remove_control_binding(&self, binding: &impl IsA<ControlBinding>) -> bool;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_set_control_binding_disabled")]
fn set_control_binding_disabled(&self, property_name: &str, disabled: bool);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_set_control_bindings_disabled")]
fn set_control_bindings_disabled(&self, disabled: bool);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_set_control_rate")]
fn set_control_rate(&self, control_rate: impl Into<Option<ClockTime>>);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_set_parent")]
fn set_parent(&self, parent: &impl IsA<Object>) -> Result<(), glib::error::BoolError>;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_suggest_next_sync")]
fn suggest_next_sync(&self) -> Option<ClockTime>;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_sync_values")]
fn sync_values(&self, timestamp: ClockTime) -> Result<(), glib::error::BoolError>;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_object_unparent")]
fn unparent(&self);
//#[doc(alias = "deep-notify")]
2021-02-28 16:30:54 +00:00
//fn connect_deep_notify<Unsupported or ignored types>(&self, detail: Option<&str>, f: F) -> SignalHandlerId;
#[doc(alias = "parent")]
fn connect_parent_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<Object>> GstObjectExt for O {
fn add_control_binding(
2020-06-09 01:06:49 +00:00
&self,
binding: &impl IsA<ControlBinding>,
2020-06-09 01:06:49 +00:00
) -> Result<(), glib::error::BoolError> {
unsafe {
2020-12-17 22:34:53 +00:00
glib::result_from_gboolean!(
2020-11-21 13:46:33 +00:00
ffi::gst_object_add_control_binding(
2020-06-09 01:06:49 +00:00
self.as_ref().to_glib_none().0,
binding.as_ref().to_glib_none().0
),
"Failed to add control binding"
)
}
}
2019-11-10 16:55:02 +00:00
fn default_error(&self, error: &glib::Error, debug: Option<&str>) {
unsafe {
2020-11-21 13:46:33 +00:00
ffi::gst_object_default_error(
self.as_ref().to_glib_none().0,
error.to_glib_none().0,
debug.to_glib_none().0,
);
}
}
2021-04-19 20:13:58 +00:00
fn control_binding(&self, property_name: &str) -> Option<ControlBinding> {
2020-06-09 01:06:49 +00:00
unsafe {
2020-11-21 13:46:33 +00:00
from_glib_full(ffi::gst_object_get_control_binding(
2020-06-09 01:06:49 +00:00
self.as_ref().to_glib_none().0,
property_name.to_glib_none().0,
))
}
}
fn control_rate(&self) -> Option<ClockTime> {
unsafe {
2020-11-21 13:46:33 +00:00
from_glib(ffi::gst_object_get_control_rate(
self.as_ref().to_glib_none().0,
))
}
}
2021-04-11 19:38:18 +00:00
fn name(&self) -> glib::GString {
2020-11-21 13:46:33 +00:00
unsafe { from_glib_full(ffi::gst_object_get_name(self.as_ref().to_glib_none().0)) }
}
2021-04-11 19:38:18 +00:00
fn parent(&self) -> Option<Object> {
2020-11-21 13:46:33 +00:00
unsafe { from_glib_full(ffi::gst_object_get_parent(self.as_ref().to_glib_none().0)) }
}
2021-04-11 19:38:18 +00:00
fn path_string(&self) -> glib::GString {
unsafe {
2020-11-21 13:46:33 +00:00
from_glib_full(ffi::gst_object_get_path_string(
self.as_ref().to_glib_none().0,
))
}
}
fn value(
&self,
property_name: &str,
timestamp: impl Into<Option<ClockTime>>,
) -> Option<glib::Value> {
2020-06-09 01:06:49 +00:00
unsafe {
2020-11-21 13:46:33 +00:00
from_glib_full(ffi::gst_object_get_value(
2020-06-09 01:06:49 +00:00
self.as_ref().to_glib_none().0,
property_name.to_glib_none().0,
timestamp.into().into_glib(),
2020-06-09 01:06:49 +00:00
))
}
}
//fn is_value_array(&self, property_name: &str, timestamp: impl Into<Option<ClockTime>>, interval: impl Into<Option<ClockTime>>, values: /*Unimplemented*/&[&Basic: Pointer]) -> bool {
2020-11-21 13:46:33 +00:00
// unsafe { TODO: call ffi:gst_object_get_value_array() }
//}
fn has_active_control_bindings(&self) -> bool {
unsafe {
2020-11-21 13:46:33 +00:00
from_glib(ffi::gst_object_has_active_control_bindings(
self.as_ref().to_glib_none().0,
))
}
}
fn has_ancestor(&self, ancestor: &impl IsA<Object>) -> bool {
unsafe {
2020-11-21 13:46:33 +00:00
from_glib(ffi::gst_object_has_ancestor(
self.as_ref().to_glib_none().0,
ancestor.as_ref().to_glib_none().0,
))
}
}
fn has_as_ancestor(&self, ancestor: &impl IsA<Object>) -> bool {
unsafe {
2020-11-21 13:46:33 +00:00
from_glib(ffi::gst_object_has_as_ancestor(
self.as_ref().to_glib_none().0,
ancestor.as_ref().to_glib_none().0,
))
}
}
fn has_as_parent(&self, parent: &impl IsA<Object>) -> bool {
unsafe {
2020-11-21 13:46:33 +00:00
from_glib(ffi::gst_object_has_as_parent(
self.as_ref().to_glib_none().0,
parent.as_ref().to_glib_none().0,
))
}
}
fn remove_control_binding(&self, binding: &impl IsA<ControlBinding>) -> bool {
2020-06-09 01:06:49 +00:00
unsafe {
2020-11-21 13:46:33 +00:00
from_glib(ffi::gst_object_remove_control_binding(
2020-06-09 01:06:49 +00:00
self.as_ref().to_glib_none().0,
binding.as_ref().to_glib_none().0,
))
}
}
fn set_control_binding_disabled(&self, property_name: &str, disabled: bool) {
unsafe {
2020-11-21 13:46:33 +00:00
ffi::gst_object_set_control_binding_disabled(
self.as_ref().to_glib_none().0,
property_name.to_glib_none().0,
disabled.into_glib(),
);
}
}
fn set_control_bindings_disabled(&self, disabled: bool) {
unsafe {
2020-11-21 13:46:33 +00:00
ffi::gst_object_set_control_bindings_disabled(
self.as_ref().to_glib_none().0,
disabled.into_glib(),
);
}
}
fn set_control_rate(&self, control_rate: impl Into<Option<ClockTime>>) {
unsafe {
2020-11-21 13:46:33 +00:00
ffi::gst_object_set_control_rate(
self.as_ref().to_glib_none().0,
control_rate.into().into_glib(),
);
}
}
fn set_parent(&self, parent: &impl IsA<Object>) -> Result<(), glib::error::BoolError> {
unsafe {
2020-12-17 22:34:53 +00:00
glib::result_from_gboolean!(
2020-11-21 13:46:33 +00:00
ffi::gst_object_set_parent(
self.as_ref().to_glib_none().0,
parent.as_ref().to_glib_none().0
),
"Failed to set parent object"
)
}
}
fn suggest_next_sync(&self) -> Option<ClockTime> {
unsafe {
2020-11-21 13:46:33 +00:00
from_glib(ffi::gst_object_suggest_next_sync(
self.as_ref().to_glib_none().0,
))
}
}
fn sync_values(&self, timestamp: ClockTime) -> Result<(), glib::error::BoolError> {
unsafe {
2020-12-17 22:34:53 +00:00
glib::result_from_gboolean!(
ffi::gst_object_sync_values(self.as_ref().to_glib_none().0, timestamp.into_glib()),
"Failed to sync values"
)
}
}
fn unparent(&self) {
unsafe {
2020-11-21 13:46:33 +00:00
ffi::gst_object_unparent(self.as_ref().to_glib_none().0);
}
}
2021-02-28 16:30:54 +00:00
//fn connect_deep_notify<Unsupported or ignored types>(&self, detail: Option<&str>, f: F) -> SignalHandlerId {
// Ignored prop: GObject.ParamSpec
//}
fn connect_parent_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_parent_trampoline<
P: IsA<Object>,
F: Fn(&P) + Send + Sync + 'static,
>(
2020-11-21 13:46:33 +00:00
this: *mut ffi::GstObject,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
2019-06-18 10:10:46 +00:00
let f: &F = &*(f as *const F);
2021-06-21 21:07:45 +00:00
f(Object::from_glib_borrow(this).unsafe_cast_ref())
2019-06-18 10:10:46 +00:00
}
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::parent\0".as_ptr() as *const _,
2020-04-13 16:11:33 +00:00
Some(transmute::<_, unsafe extern "C" fn()>(
notify_parent_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}