1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603
// 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::{ffi, ClockTime, ControlBinding};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// [`Object`][crate::Object] provides a root for the object hierarchy tree filed in by the
/// GStreamer library. It is currently a thin wrapper on top of
/// `GInitiallyUnowned`. It is an abstract class that is not very usable on its own.
///
/// [`Object`][crate::Object] gives us basic refcounting, parenting functionality and locking.
/// Most of the functions are just extended for special GStreamer needs and can be
/// found under the same name in the base class of [`Object`][crate::Object] which is [`glib::Object`][crate::glib::Object]
/// (e.g. `g_object_ref()` becomes `gst_object_ref()`).
///
/// Since [`Object`][crate::Object] derives from `GInitiallyUnowned`, it also inherits the
/// floating reference. Be aware that functions such as [`GstBinExt::add()`][crate::prelude::GstBinExt::add()] and
/// [`ElementExt::add_pad()`][crate::prelude::ElementExt::add_pad()] take ownership of the floating reference.
///
/// In contrast to [`glib::Object`][crate::glib::Object] instances, [`Object`][crate::Object] adds a name property. The functions
/// `gst_object_set_name()` and [`GstObjectExt::name()`][crate::prelude::GstObjectExt::name()] are used to set/get the name
/// of the object.
///
/// ## controlled properties
///
/// Controlled properties offers a lightweight way to adjust gobject properties
/// over stream-time. It works by using time-stamped value pairs that are queued
/// for element-properties. At run-time the elements continuously pull value
/// changes for the current stream-time.
///
/// What needs to be changed in a [`Element`][crate::Element]?
/// Very little - it is just two steps to make a plugin controllable!
///
/// * mark gobject-properties paramspecs that make sense to be controlled,
/// by GST_PARAM_CONTROLLABLE.
///
/// * when processing data (get, chain, loop function) at the beginning call
/// gst_object_sync_values(element,timestamp).
/// This will make the controller update all GObject properties that are
/// under its control with the current values based on the timestamp.
///
/// What needs to be done in applications? Again it's not a lot to change.
///
/// * create a [`ControlSource`][crate::ControlSource].
/// csource = gst_interpolation_control_source_new ();
/// g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
///
/// * Attach the [`ControlSource`][crate::ControlSource] on the controller to a property.
/// gst_object_add_control_binding (object, gst_direct_control_binding_new (object, "prop1", csource));
///
/// * Set the control values
/// gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,0 * GST_SECOND, value1);
/// gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,1 * GST_SECOND, value2);
///
/// * start your pipeline
///
/// This is an Abstract Base Class, you cannot instantiate it.
///
/// ## Properties
///
///
/// #### `name`
/// Readable | Writeable | Construct
///
///
/// #### `parent`
/// The parent of the object. Please note, that when changing the 'parent'
/// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::Object#deep-notify]
/// signals due to locking issues. In some cases one can use
/// [`element-added`][struct@crate::Bin#element-added] or [`element-removed`][struct@crate::Bin#element-removed] signals on the parent to
/// achieve a similar effect.
///
/// Readable | Writeable
///
/// ## Signals
///
///
/// #### `deep-notify`
/// The deep notify signal is used to be notified of property changes. It is
/// typically attached to the toplevel bin to receive notifications from all
/// the elements contained in that bin.
///
/// Detailed
///
/// # Implements
///
/// [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`]
#[doc(alias = "GstObject")]
pub struct Object(Object<ffi::GstObject, ffi::GstObjectClass>);
match fn {
type_ => || ffi::gst_object_get_type(),
}
}
impl Object {
pub const NONE: Option<&'static Object> = None;
/// Checks to see if there is any object named `name` in `list`. This function
/// does not do any locking of any kind. You might want to protect the
/// provided list with the lock of the owner of the list. This function
/// will lock each [`Object`][crate::Object] in the list to compare the name, so be
/// careful when passing a list with a locked object.
/// ## `list`
/// a list of [`Object`][crate::Object] to
/// check through
/// ## `name`
/// the name to search for
///
/// # Returns
///
/// [`true`] if a [`Object`][crate::Object] named `name` does not appear in `list`,
/// [`false`] if it does.
///
/// MT safe. Grabs and releases the LOCK of each object in the list.
#[doc(alias = "gst_object_check_uniqueness")]
pub fn check_uniqueness(list: &[Object], name: &str) -> bool {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::gst_object_check_uniqueness(
list.to_glib_none().0,
name.to_glib_none().0,
))
}
}
//#[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]) {
// unsafe { TODO: call ffi:gst_object_default_deep_notify() }
//}
//#[doc(alias = "gst_object_replace")]
//pub fn replace(oldobj: Option<impl IsA<Object>>, newobj: Option<&impl IsA<Object>>) -> bool {
// unsafe { TODO: call ffi:gst_object_replace() }
//}
}
impl std::fmt::Display for Object {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(&GstObjectExt::name(self))
}
}
unsafe impl Send for Object {}
unsafe impl Sync for Object {}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Object>> Sealed for T {}
}
/// Trait containing all [`struct@Object`] methods.
///
/// # Implementors
///
/// [`Allocator`][struct@crate::Allocator], [`BufferPool`][struct@crate::BufferPool], [`Bus`][struct@crate::Bus], [`Clock`][struct@crate::Clock], [`ControlBinding`][struct@crate::ControlBinding], [`ControlSource`][struct@crate::ControlSource], [`DeviceMonitor`][struct@crate::DeviceMonitor], [`DeviceProvider`][struct@crate::DeviceProvider], [`Device`][struct@crate::Device], [`Element`][struct@crate::Element], [`Object`][struct@crate::Object], [`PadTemplate`][struct@crate::PadTemplate], [`Pad`][struct@crate::Pad], [`PluginFeature`][struct@crate::PluginFeature], [`Plugin`][struct@crate::Plugin], [`Registry`][struct@crate::Registry], [`StreamCollection`][struct@crate::StreamCollection], [`Stream`][struct@crate::Stream], [`TaskPool`][struct@crate::TaskPool], [`Task`][struct@crate::Task], [`Tracer`][struct@crate::Tracer]
pub trait GstObjectExt: IsA<Object> + sealed::Sealed + 'static {
/// Attach the [`ControlBinding`][crate::ControlBinding] to the object. If there already was a
/// [`ControlBinding`][crate::ControlBinding] for this property it will be replaced.
///
/// The object's reference count will be incremented, and any floating
/// reference will be removed (see `gst_object_ref_sink()`)
/// ## `binding`
/// the [`ControlBinding`][crate::ControlBinding] that should be used
///
/// # Returns
///
/// [`false`] if the given `binding` has not been setup for this object or
/// has been setup for a non suitable property, [`true`] otherwise.
#[doc(alias = "gst_object_add_control_binding")]
fn add_control_binding(
&self,
binding: &impl IsA<ControlBinding>,
) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::gst_object_add_control_binding(
self.as_ref().to_glib_none().0,
binding.as_ref().to_glib_none().0
),
"Failed to add control binding"
)
}
}
/// A default error function that uses `g_printerr()` to display the error message
/// and the optional debug string..
///
/// The default handler will simply print the error string using g_print.
/// ## `error`
/// the GError.
/// ## `debug`
/// an additional debug information string, or [`None`]
#[doc(alias = "gst_object_default_error")]
fn default_error(&self, error: &glib::Error, debug: Option<&str>) {
unsafe {
ffi::gst_object_default_error(
self.as_ref().to_glib_none().0,
error.to_glib_none().0,
debug.to_glib_none().0,
);
}
}
/// Gets the corresponding [`ControlBinding`][crate::ControlBinding] for the property. This should be
/// unreferenced again after use.
/// ## `property_name`
/// name of the property
///
/// # Returns
///
/// the [`ControlBinding`][crate::ControlBinding] for
/// `property_name` or [`None`] if the property is not controlled.
#[doc(alias = "gst_object_get_control_binding")]
#[doc(alias = "get_control_binding")]
fn control_binding(&self, property_name: &str) -> Option<ControlBinding> {
unsafe {
from_glib_full(ffi::gst_object_get_control_binding(
self.as_ref().to_glib_none().0,
property_name.to_glib_none().0,
))
}
}
/// Obtain the control-rate for this `self`. Audio processing [`Element`][crate::Element]
/// objects will use this rate to sub-divide their processing loop and call
/// [`sync_values()`][Self::sync_values()] in between. The length of the processing segment
/// should be up to `control`-rate nanoseconds.
///
/// If the `self` is not under property control, this will return
/// `GST_CLOCK_TIME_NONE`. This allows the element to avoid the sub-dividing.
///
/// The control-rate is not expected to change if the element is in
/// [`State::Paused`][crate::State::Paused] or [`State::Playing`][crate::State::Playing].
///
/// # Returns
///
/// the control rate in nanoseconds
#[doc(alias = "gst_object_get_control_rate")]
#[doc(alias = "get_control_rate")]
fn control_rate(&self) -> Option<ClockTime> {
unsafe {
from_glib(ffi::gst_object_get_control_rate(
self.as_ref().to_glib_none().0,
))
}
}
/// Returns a copy of the name of `self`.
/// Caller should `g_free()` the return value after usage.
/// For a nameless object, this returns [`None`], which you can safely `g_free()`
/// as well.
///
/// Free-function: g_free
///
/// # Returns
///
/// the name of `self`. `g_free()`
/// after usage.
///
/// MT safe. This function grabs and releases `self`'s LOCK.
#[doc(alias = "gst_object_get_name")]
#[doc(alias = "get_name")]
fn name(&self) -> glib::GString {
unsafe { from_glib_full(ffi::gst_object_get_name(self.as_ref().to_glib_none().0)) }
}
/// Returns the parent of `self`. This function increases the refcount
/// of the parent object so you should `gst_object_unref()` it after usage.
///
/// # Returns
///
/// parent of `self`, this can be
/// [`None`] if `self` has no parent. unref after usage.
///
/// MT safe. Grabs and releases `self`'s LOCK.
#[doc(alias = "gst_object_get_parent")]
#[doc(alias = "get_parent")]
#[must_use]
fn parent(&self) -> Option<Object> {
unsafe { from_glib_full(ffi::gst_object_get_parent(self.as_ref().to_glib_none().0)) }
}
/// Generates a string describing the path of `self` in
/// the object hierarchy. Only useful (or used) for debugging.
///
/// Free-function: g_free
///
/// # Returns
///
/// a string describing the path of `self`. You must
/// `g_free()` the string after usage.
///
/// MT safe. Grabs and releases the [`Object`][crate::Object]'s LOCK for all objects
/// in the hierarchy.
#[doc(alias = "gst_object_get_path_string")]
#[doc(alias = "get_path_string")]
fn path_string(&self) -> glib::GString {
unsafe {
from_glib_full(ffi::gst_object_get_path_string(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the value for the given controlled property at the requested time.
/// ## `property_name`
/// the name of the property to get
/// ## `timestamp`
/// the time the control-change should be read from
///
/// # Returns
///
/// the GValue of the property at the given time,
/// or [`None`] if the property isn't controlled.
#[doc(alias = "gst_object_get_value")]
#[doc(alias = "get_value")]
fn value(
&self,
property_name: &str,
timestamp: impl Into<Option<ClockTime>>,
) -> Option<glib::Value> {
unsafe {
from_glib_full(ffi::gst_object_get_value(
self.as_ref().to_glib_none().0,
property_name.to_glib_none().0,
timestamp.into().into_glib(),
))
}
}
//#[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 {
// unsafe { TODO: call ffi:gst_object_get_value_array() }
//}
/// Check if the `self` has active controlled properties.
///
/// # Returns
///
/// [`true`] if the object has active controlled properties
#[doc(alias = "gst_object_has_active_control_bindings")]
fn has_active_control_bindings(&self) -> bool {
unsafe {
from_glib(ffi::gst_object_has_active_control_bindings(
self.as_ref().to_glib_none().0,
))
}
}
/// Check if `self` has an ancestor `ancestor` somewhere up in
/// the hierarchy. One can e.g. check if a [`Element`][crate::Element] is inside a [`Pipeline`][crate::Pipeline].
///
/// # Deprecated
///
/// Use [`has_as_ancestor()`][Self::has_as_ancestor()] instead.
///
/// MT safe. Grabs and releases `self`'s locks.
/// ## `ancestor`
/// a [`Object`][crate::Object] to check as ancestor
///
/// # Returns
///
/// [`true`] if `ancestor` is an ancestor of `self`.
#[doc(alias = "gst_object_has_ancestor")]
fn has_ancestor(&self, ancestor: &impl IsA<Object>) -> bool {
unsafe {
from_glib(ffi::gst_object_has_ancestor(
self.as_ref().to_glib_none().0,
ancestor.as_ref().to_glib_none().0,
))
}
}
/// Check if `self` has an ancestor `ancestor` somewhere up in
/// the hierarchy. One can e.g. check if a [`Element`][crate::Element] is inside a [`Pipeline`][crate::Pipeline].
/// ## `ancestor`
/// a [`Object`][crate::Object] to check as ancestor
///
/// # Returns
///
/// [`true`] if `ancestor` is an ancestor of `self`.
///
/// MT safe. Grabs and releases `self`'s locks.
#[doc(alias = "gst_object_has_as_ancestor")]
fn has_as_ancestor(&self, ancestor: &impl IsA<Object>) -> bool {
unsafe {
from_glib(ffi::gst_object_has_as_ancestor(
self.as_ref().to_glib_none().0,
ancestor.as_ref().to_glib_none().0,
))
}
}
/// Check if `parent` is the parent of `self`.
/// E.g. a [`Element`][crate::Element] can check if it owns a given [`Pad`][crate::Pad].
/// ## `parent`
/// a [`Object`][crate::Object] to check as parent
///
/// # Returns
///
/// [`false`] if either `self` or `parent` is [`None`]. [`true`] if `parent` is
/// the parent of `self`. Otherwise [`false`].
///
/// MT safe. Grabs and releases `self`'s locks.
#[doc(alias = "gst_object_has_as_parent")]
fn has_as_parent(&self, parent: &impl IsA<Object>) -> bool {
unsafe {
from_glib(ffi::gst_object_has_as_parent(
self.as_ref().to_glib_none().0,
parent.as_ref().to_glib_none().0,
))
}
}
/// Removes the corresponding [`ControlBinding`][crate::ControlBinding]. If it was the
/// last ref of the binding, it will be disposed.
/// ## `binding`
/// the binding
///
/// # Returns
///
/// [`true`] if the binding could be removed.
#[doc(alias = "gst_object_remove_control_binding")]
fn remove_control_binding(&self, binding: &impl IsA<ControlBinding>) -> bool {
unsafe {
from_glib(ffi::gst_object_remove_control_binding(
self.as_ref().to_glib_none().0,
binding.as_ref().to_glib_none().0,
))
}
}
/// This function is used to disable the control bindings on a property for
/// some time, i.e. [`sync_values()`][Self::sync_values()] will do nothing for the
/// property.
/// ## `property_name`
/// property to disable
/// ## `disabled`
/// boolean that specifies whether to disable the controller
/// or not.
#[doc(alias = "gst_object_set_control_binding_disabled")]
fn set_control_binding_disabled(&self, property_name: &str, disabled: bool) {
unsafe {
ffi::gst_object_set_control_binding_disabled(
self.as_ref().to_glib_none().0,
property_name.to_glib_none().0,
disabled.into_glib(),
);
}
}
/// This function is used to disable all controlled properties of the `self` for
/// some time, i.e. [`sync_values()`][Self::sync_values()] will do nothing.
/// ## `disabled`
/// boolean that specifies whether to disable the controller
/// or not.
#[doc(alias = "gst_object_set_control_bindings_disabled")]
fn set_control_bindings_disabled(&self, disabled: bool) {
unsafe {
ffi::gst_object_set_control_bindings_disabled(
self.as_ref().to_glib_none().0,
disabled.into_glib(),
);
}
}
/// Change the control-rate for this `self`. Audio processing [`Element`][crate::Element]
/// objects will use this rate to sub-divide their processing loop and call
/// [`sync_values()`][Self::sync_values()] in between. The length of the processing segment
/// should be up to `control`-rate nanoseconds.
///
/// The control-rate should not change if the element is in [`State::Paused`][crate::State::Paused] or
/// [`State::Playing`][crate::State::Playing].
/// ## `control_rate`
/// the new control-rate in nanoseconds.
#[doc(alias = "gst_object_set_control_rate")]
fn set_control_rate(&self, control_rate: impl Into<Option<ClockTime>>) {
unsafe {
ffi::gst_object_set_control_rate(
self.as_ref().to_glib_none().0,
control_rate.into().into_glib(),
);
}
}
/// Sets the parent of `self` to `parent`. The object's reference count will
/// be incremented, and any floating reference will be removed (see `gst_object_ref_sink()`).
/// ## `parent`
/// new parent of object
///
/// # Returns
///
/// [`true`] if `parent` could be set or [`false`] when `self`
/// already had a parent or `self` and `parent` are the same.
///
/// MT safe. Grabs and releases `self`'s LOCK.
#[doc(alias = "gst_object_set_parent")]
#[doc(alias = "parent")]
fn set_parent(&self, parent: &impl IsA<Object>) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::gst_object_set_parent(
self.as_ref().to_glib_none().0,
parent.as_ref().to_glib_none().0
),
"Failed to set parent object"
)
}
}
/// Returns a suggestion for timestamps where buffers should be split
/// to get best controller results.
///
/// # Returns
///
/// Returns the suggested timestamp or `GST_CLOCK_TIME_NONE`
/// if no control-rate was set.
#[doc(alias = "gst_object_suggest_next_sync")]
fn suggest_next_sync(&self) -> Option<ClockTime> {
unsafe {
from_glib(ffi::gst_object_suggest_next_sync(
self.as_ref().to_glib_none().0,
))
}
}
/// Sets the properties of the object, according to the `GstControlSources` that
/// (maybe) handle them and for the given timestamp.
///
/// If this function fails, it is most likely the application developers fault.
/// Most probably the control sources are not setup correctly.
/// ## `timestamp`
/// the time that should be processed
///
/// # Returns
///
/// [`true`] if the controller values could be applied to the object
/// properties, [`false`] otherwise
#[doc(alias = "gst_object_sync_values")]
fn sync_values(&self, timestamp: ClockTime) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::gst_object_sync_values(self.as_ref().to_glib_none().0, timestamp.into_glib()),
"Failed to sync values"
)
}
}
/// Clear the parent of `self`, removing the associated reference.
/// This function decreases the refcount of `self`.
///
/// MT safe. Grabs and releases `self`'s lock.
#[doc(alias = "gst_object_unparent")]
fn unparent(&self) {
unsafe {
ffi::gst_object_unparent(self.as_ref().to_glib_none().0);
}
}
//#[doc(alias = "deep-notify")]
//fn connect_deep_notify<Unsupported or ignored types>(&self, detail: Option<&str>, f: F) -> SignalHandlerId {
// Ignored prop: GObject.ParamSpec
//}
#[doc(alias = "parent")]
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,
>(
this: *mut ffi::GstObject,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Object::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::parent\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_parent_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<Object>> GstObjectExt for O {}