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
42mod sealed {
43    pub trait Sealed {}
44    impl<T: super::IsA<super::GhostPad>> Sealed for T {}
45}
46
47/// Trait containing all [`struct@GhostPad`] methods.
48///
49/// # Implementors
50///
51/// [`GhostPad`][struct@crate::GhostPad]
52pub trait GhostPadExt: IsA<GhostPad> + sealed::Sealed + 'static {
53    /// Get the target pad of `self`. Unref target pad after usage.
54    ///
55    /// # Returns
56    ///
57    /// the target [`Pad`][crate::Pad], can be
58    /// [`None`] if the ghostpad has no target set. Unref target pad after
59    /// usage.
60    #[doc(alias = "gst_ghost_pad_get_target")]
61    #[doc(alias = "get_target")]
62    fn target(&self) -> Option<Pad> {
63        unsafe {
64            from_glib_full(ffi::gst_ghost_pad_get_target(
65                self.as_ref().to_glib_none().0,
66            ))
67        }
68    }
69
70    /// Set the new target of the ghostpad `self`. Any existing target
71    /// is unlinked and links to the new target are established. if `newtarget` is
72    /// [`None`] the target will be cleared.
73    /// ## `newtarget`
74    /// the new pad target
75    ///
76    /// # Returns
77    ///
78    /// [`true`] if the new target could be set. This function
79    ///  can return [`false`] when the internal pads could not be linked.
80    #[doc(alias = "gst_ghost_pad_set_target")]
81    fn set_target(&self, newtarget: Option<&impl IsA<Pad>>) -> Result<(), glib::error::BoolError> {
82        unsafe {
83            glib::result_from_gboolean!(
84                ffi::gst_ghost_pad_set_target(
85                    self.as_ref().to_glib_none().0,
86                    newtarget.map(|p| p.as_ref()).to_glib_none().0
87                ),
88                "Failed to set target"
89            )
90        }
91    }
92}
93
94impl<O: IsA<GhostPad>> GhostPadExt for O {}