gstreamer/auto/
ghost_pad.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{ffi, Object, Pad, ProxyPad};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// GhostPads are useful when organizing pipelines with [`Bin`][crate::Bin] like elements.
11    /// The idea here is to create hierarchical element graphs. The bin element
12    /// contains a sub-graph. Now one would like to treat the bin-element like any
13    /// other [`Element`][crate::Element]. This is where GhostPads come into play. A GhostPad acts as
14    /// a proxy for another pad. Thus the bin can have sink and source ghost-pads
15    /// that are associated with sink and source pads of the child elements.
16    ///
17    /// If the target pad is known at creation time, [`with_target()`][Self::with_target()] is the
18    /// function to use to get a ghost-pad. Otherwise one can use [`new()`][Self::new()]
19    /// to create the ghost-pad and use [`GhostPadExt::set_target()`][crate::prelude::GhostPadExt::set_target()] to establish the
20    /// association later on.
21    ///
22    /// Note that GhostPads add overhead to the data processing of a pipeline.
23    ///
24    /// # Implements
25    ///
26    /// [`GhostPadExt`][trait@crate::prelude::GhostPadExt], [`ProxyPadExt`][trait@crate::prelude::ProxyPadExt], [`PadExt`][trait@crate::prelude::PadExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`ProxyPadExtManual`][trait@crate::prelude::ProxyPadExtManual], [`PadExtManual`][trait@crate::prelude::PadExtManual]
27    #[doc(alias = "GstGhostPad")]
28    pub struct GhostPad(Object<ffi::GstGhostPad, ffi::GstGhostPadClass>) @extends ProxyPad, Pad, Object;
29
30    match fn {
31        type_ => || ffi::gst_ghost_pad_get_type(),
32    }
33}
34
35impl GhostPad {
36    pub const NONE: Option<&'static GhostPad> = None;
37}
38
39unsafe impl Send for GhostPad {}
40unsafe impl Sync for GhostPad {}
41
42/// Trait containing all [`struct@GhostPad`] methods.
43///
44/// # Implementors
45///
46/// [`GhostPad`][struct@crate::GhostPad]
47pub trait GhostPadExt: IsA<GhostPad> + 'static {
48    /// Get the target pad of `self`. Unref target pad after usage.
49    ///
50    /// # Returns
51    ///
52    /// the target [`Pad`][crate::Pad], can be
53    /// [`None`] if the ghostpad has no target set. Unref target pad after
54    /// usage.
55    #[doc(alias = "gst_ghost_pad_get_target")]
56    #[doc(alias = "get_target")]
57    fn target(&self) -> Option<Pad> {
58        unsafe {
59            from_glib_full(ffi::gst_ghost_pad_get_target(
60                self.as_ref().to_glib_none().0,
61            ))
62        }
63    }
64
65    /// Set the new target of the ghostpad `self`. Any existing target
66    /// is unlinked and links to the new target are established. if `newtarget` is
67    /// [`None`] the target will be cleared.
68    /// ## `newtarget`
69    /// the new pad target
70    ///
71    /// # Returns
72    ///
73    /// [`true`] if the new target could be set. This function
74    ///  can return [`false`] when the internal pads could not be linked.
75    #[doc(alias = "gst_ghost_pad_set_target")]
76    fn set_target(&self, newtarget: Option<&impl IsA<Pad>>) -> Result<(), glib::error::BoolError> {
77        unsafe {
78            glib::result_from_gboolean!(
79                ffi::gst_ghost_pad_set_target(
80                    self.as_ref().to_glib_none().0,
81                    newtarget.map(|p| p.as_ref()).to_glib_none().0
82                ),
83                "Failed to set target"
84            )
85        }
86    }
87}
88
89impl<O: IsA<GhostPad>> GhostPadExt for O {}