Skip to main content

gstreamer/auto/
bin.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::{ChildProxy, Element, ElementFlags, Object, Pad, PadDirection, ffi};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    /// [`Bin`][crate::Bin] is an element that can contain other [`Element`][crate::Element], allowing them to be
17    /// managed as a group.
18    /// Pads from the child elements can be ghosted to the bin, see [`GhostPad`][crate::GhostPad].
19    /// This makes the bin look like any other elements and enables creation of
20    /// higher-level abstraction elements.
21    ///
22    /// A new [`Bin`][crate::Bin] is created with [`new()`][Self::new()]. Use a [`Pipeline`][crate::Pipeline] instead if you
23    /// want to create a toplevel bin because a normal bin doesn't have a bus or
24    /// handle clock distribution of its own.
25    ///
26    /// After the bin has been created you will typically add elements to it with
27    /// [`GstBinExt::add()`][crate::prelude::GstBinExt::add()]. You can remove elements with [`GstBinExt::remove()`][crate::prelude::GstBinExt::remove()].
28    ///
29    /// An element can be retrieved from a bin with [`GstBinExt::by_name()`][crate::prelude::GstBinExt::by_name()], using the
30    /// elements name. [`GstBinExt::by_name_recurse_up()`][crate::prelude::GstBinExt::by_name_recurse_up()] is mainly used for internal
31    /// purposes and will query the parent bins when the element is not found in the
32    /// current bin.
33    ///
34    /// An iterator of elements in a bin can be retrieved with
35    /// [`GstBinExtManual::iterate_elements()`][crate::prelude::GstBinExtManual::iterate_elements()]. Various other iterators exist to retrieve the
36    /// elements in a bin.
37    ///
38    /// `gst_object_unref()` is used to drop your reference to the bin.
39    ///
40    /// The [`element-added`][struct@crate::Bin#element-added] signal is fired whenever a new element is added to
41    /// the bin. Likewise the [`element-removed`][struct@crate::Bin#element-removed] signal is fired whenever an
42    /// element is removed from the bin.
43    ///
44    /// A [`Bin`][crate::Bin] internally intercepts every [`Message`][crate::Message] posted by its children and
45    /// implements the following default behaviour for each of them:
46    ///
47    /// * `GST_MESSAGE_EOS`: This message is only posted by sinks in the PLAYING
48    /// state. If all sinks posted the EOS message, this bin will post and EOS
49    /// message upwards.
50    ///
51    /// * `GST_MESSAGE_SEGMENT_START`: Just collected and never forwarded upwards.
52    ///  The messages are used to decide when all elements have completed playback
53    ///  of their segment.
54    ///
55    /// * `GST_MESSAGE_SEGMENT_DONE`: Is posted by [`Bin`][crate::Bin] when all elements that posted
56    ///  a SEGMENT_START have posted a SEGMENT_DONE.
57    ///
58    /// * `GST_MESSAGE_DURATION_CHANGED`: Is posted by an element that detected a change
59    ///  in the stream duration. The duration change is posted to the
60    ///  application so that it can refetch the new duration with a duration
61    ///  query.
62    ///
63    ///  Note that these messages can be posted before the bin is prerolled, in which
64    ///  case the duration query might fail.
65    ///
66    ///  Note also that there might be a discrepancy (due to internal buffering/queueing)
67    ///  between the stream being currently displayed and the returned duration query.
68    ///
69    ///  Applications might want to also query for duration (and changes) by
70    ///  listening to the `GST_MESSAGE_STREAM_START` message, signaling the active start
71    ///  of a (new) stream.
72    ///
73    /// * `GST_MESSAGE_CLOCK_LOST`: This message is posted by an element when it
74    ///  can no longer provide a clock.
75    ///
76    ///  The default bin behaviour is to check if the lost clock was the one provided
77    ///  by the bin. If so and the bin is currently in the PLAYING state, the message
78    ///  is forwarded to the bin parent.
79    ///
80    ///  This message is also generated when a clock provider is removed from
81    ///  the bin. If this message is received by the application, it should
82    ///  PAUSE the pipeline and set it back to PLAYING to force a new clock
83    ///  distribution.
84    ///
85    /// * `GST_MESSAGE_CLOCK_PROVIDE`: This message is generated when an element
86    ///  can provide a clock. This mostly happens when a new clock
87    ///  provider is added to the bin.
88    ///
89    ///  The default behaviour of the bin is to mark the currently selected clock as
90    ///  dirty, which will perform a clock recalculation the next time the bin is
91    ///  asked to provide a clock.
92    ///
93    ///  This message is never sent to the application but is forwarded to
94    ///  the parent of the bin.
95    ///
96    /// * OTHERS: posted upwards.
97    ///
98    /// A [`Bin`][crate::Bin] implements the following default behaviour for answering to a
99    /// [`Query`][crate::Query]:
100    ///
101    /// * [`QueryType::Duration`][crate::QueryType::Duration]: The bin will forward the query to all sink
102    ///  elements contained within and will return the maximum value.
103    ///  If no sinks are available in the bin, the query fails.
104    ///
105    /// * [`QueryType::Position`][crate::QueryType::Position]: The query is sent to all sink elements in the bin and the
106    ///  MAXIMUM of all values is returned. If no sinks are available in the bin,
107    ///  the query fails.
108    ///
109    /// * OTHERS: the query is forwarded to all sink elements, the result
110    ///  of the first sink that answers the query successfully is returned. If no
111    ///  sink is in the bin, the query fails.
112    ///
113    /// A [`Bin`][crate::Bin] will by default forward any event sent to it to all sink
114    /// ( [`EventTypeFlags::UPSTREAM`][crate::EventTypeFlags::UPSTREAM] ) or source ( [`EventTypeFlags::DOWNSTREAM`][crate::EventTypeFlags::DOWNSTREAM] ) elements
115    /// depending on the event type.
116    ///
117    /// If all the elements return [`true`], the bin will also return [`true`], else [`false`]
118    /// is returned. If no elements of the required type are in the bin, the event
119    /// handler will return [`true`].
120    ///
121    /// ## Properties
122    ///
123    ///
124    /// #### `async-handling`
125    ///  If set to [`true`], the bin will handle asynchronous state changes.
126    /// This should be used only if the bin subclass is modifying the state
127    /// of its children on its own.
128    ///
129    /// Readable | Writeable
130    ///
131    ///
132    /// #### `message-forward`
133    ///  Forward all children messages, even those that would normally be filtered by
134    /// the bin. This can be interesting when one wants to be notified of the EOS
135    /// state of individual elements, for example.
136    ///
137    /// The messages are converted to an ELEMENT message with the bin as the
138    /// source. The structure of the message is named `GstBinForwarded` and contains
139    /// a field named `message` that contains the original forwarded [`Message`][crate::Message].
140    ///
141    /// Readable | Writeable
142    /// <details><summary><h4>Object</h4></summary>
143    ///
144    ///
145    /// #### `name`
146    ///  Readable | Writeable | Construct
147    ///
148    ///
149    /// #### `parent`
150    ///  The parent of the object. Please note, that when changing the 'parent'
151    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::Object#deep-notify]
152    /// signals due to locking issues. In some cases one can use
153    /// [`element-added`][struct@crate::Bin#element-added] or [`element-removed`][struct@crate::Bin#element-removed] signals on the parent to
154    /// achieve a similar effect.
155    ///
156    /// Readable | Writeable
157    /// </details>
158    ///
159    /// ## Signals
160    ///
161    ///
162    /// #### `deep-element-added`
163    ///  Will be emitted after the element was added to `sub_bin`.
164    ///
165    ///
166    ///
167    ///
168    /// #### `deep-element-removed`
169    ///  Will be emitted after the element was removed from `sub_bin`.
170    ///
171    ///
172    ///
173    ///
174    /// #### `do-latency`
175    ///  Will be emitted when the bin needs to perform latency calculations. This
176    /// signal is only emitted for toplevel bins or when [`async-handling`][struct@crate::Bin#async-handling] is
177    /// enabled.
178    ///
179    /// Only one signal handler is invoked. If no signals are connected, the
180    /// default handler is invoked, which will query and distribute the lowest
181    /// possible latency to all sinks.
182    ///
183    /// Connect to this signal if the default latency calculations are not
184    /// sufficient, like when you need different latencies for different sinks in
185    /// the same pipeline.
186    ///
187    ///
188    ///
189    ///
190    /// #### `element-added`
191    ///  Will be emitted after the element was added to the bin.
192    ///
193    ///
194    ///
195    ///
196    /// #### `element-removed`
197    ///  Will be emitted after the element was removed from the bin.
198    ///
199    ///
200    /// <details><summary><h4>Element</h4></summary>
201    ///
202    ///
203    /// #### `no-more-pads`
204    ///  This signals that the element will not generate more dynamic pads.
205    /// Note that this signal will usually be emitted from the context of
206    /// the streaming thread.
207    ///
208    ///
209    ///
210    ///
211    /// #### `pad-added`
212    ///  a new [`Pad`][crate::Pad] has been added to the element. Note that this signal will
213    /// usually be emitted from the context of the streaming thread. Also keep in
214    /// mind that if you add new elements to the pipeline in the signal handler
215    /// you will need to set them to the desired target state with
216    /// [`ElementExt::set_state()`][crate::prelude::ElementExt::set_state()] or [`ElementExt::sync_state_with_parent()`][crate::prelude::ElementExt::sync_state_with_parent()].
217    ///
218    ///
219    ///
220    ///
221    /// #### `pad-removed`
222    ///  a [`Pad`][crate::Pad] has been removed from the element
223    ///
224    ///
225    /// </details>
226    /// <details><summary><h4>Object</h4></summary>
227    ///
228    ///
229    /// #### `deep-notify`
230    ///  The deep notify signal is used to be notified of property changes. It is
231    /// typically attached to the toplevel bin to receive notifications from all
232    /// the elements contained in that bin.
233    ///
234    /// Detailed
235    /// </details>
236    /// <details><summary><h4>ChildProxy</h4></summary>
237    ///
238    ///
239    /// #### `child-added`
240    ///  Will be emitted after the `object` was added to the `child_proxy`.
241    ///
242    ///
243    ///
244    ///
245    /// #### `child-removed`
246    ///  Will be emitted after the `object` was removed from the `child_proxy`.
247    ///
248    ///
249    /// </details>
250    ///
251    /// # Implements
252    ///
253    /// [`GstBinExt`][trait@crate::prelude::GstBinExt], [`ElementExt`][trait@crate::prelude::ElementExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`ChildProxyExt`][trait@crate::prelude::ChildProxyExt], [`ElementExtManual`][trait@crate::prelude::ElementExtManual], [`ChildProxyExtManual`][trait@crate::prelude::ChildProxyExtManual]
254    #[doc(alias = "GstBin")]
255    pub struct Bin(Object<ffi::GstBin, ffi::GstBinClass>) @extends Element, Object, @implements ChildProxy;
256
257    match fn {
258        type_ => || ffi::gst_bin_get_type(),
259    }
260}
261
262impl Bin {
263    pub const NONE: Option<&'static Bin> = None;
264}
265
266unsafe impl Send for Bin {}
267unsafe impl Sync for Bin {}
268
269/// Trait containing all [`struct@Bin`] methods.
270///
271/// # Implementors
272///
273/// [`Bin`][struct@crate::Bin], [`Pipeline`][struct@crate::Pipeline]
274pub trait GstBinExt: IsA<Bin> + 'static {
275    /// Adds the given element to the bin. Sets the element's parent, and thus
276    /// takes ownership of the element. An element can only be added to one bin.
277    ///
278    /// If the element's pads are linked to other pads, the pads will be unlinked
279    /// before the element is added to the bin.
280    ///
281    /// > When you add an element to an already-running pipeline, you will have to
282    /// > take care to set the state of the newly-added element to the desired
283    /// > state (usually PLAYING or PAUSED, same you set the pipeline to originally)
284    /// > with [`ElementExt::set_state()`][crate::prelude::ElementExt::set_state()], or use [`ElementExt::sync_state_with_parent()`][crate::prelude::ElementExt::sync_state_with_parent()].
285    /// > The bin or pipeline will not take care of this for you.
286    /// ## `element`
287    /// the [`Element`][crate::Element] to add
288    ///
289    /// # Returns
290    ///
291    /// [`true`] if the element could be added, [`false`] if
292    /// the bin does not want to accept the element.
293    #[doc(alias = "gst_bin_add")]
294    fn add(&self, element: &impl IsA<Element>) -> Result<(), glib::error::BoolError> {
295        unsafe {
296            glib::result_from_gboolean!(
297                ffi::gst_bin_add(
298                    self.as_ref().to_glib_none().0,
299                    element.as_ref().to_glib_none().0
300                ),
301                "Failed to add element"
302            )
303        }
304    }
305
306    /// Recursively looks for elements with an unlinked pad of the given
307    /// direction within the specified bin and returns an unlinked pad
308    /// if one is found, or [`None`] otherwise. If a pad is found, the caller
309    /// owns a reference to it and should use `gst_object_unref()` on the
310    /// pad when it is not needed any longer.
311    /// ## `direction`
312    /// whether to look for an unlinked source or sink pad
313    ///
314    /// # Returns
315    ///
316    /// unlinked pad of the given
317    /// direction.
318    #[doc(alias = "gst_bin_find_unlinked_pad")]
319    fn find_unlinked_pad(&self, direction: PadDirection) -> Option<Pad> {
320        unsafe {
321            from_glib_full(ffi::gst_bin_find_unlinked_pad(
322                self.as_ref().to_glib_none().0,
323                direction.into_glib(),
324            ))
325        }
326    }
327
328    /// Looks for an element inside the bin that implements the given
329    /// interface. If such an element is found, it returns the element.
330    /// You can cast this element to the given interface afterwards. If you want
331    /// all elements that implement the interface, use
332    /// [`GstBinExtManual::iterate_all_by_interface()`][crate::prelude::GstBinExtManual::iterate_all_by_interface()]. This function recurses into child bins.
333    /// ## `iface`
334    /// the `GType` of an interface
335    ///
336    /// # Returns
337    ///
338    /// A [`Element`][crate::Element] inside the bin
339    /// implementing the interface
340    #[doc(alias = "gst_bin_get_by_interface")]
341    #[doc(alias = "get_by_interface")]
342    fn by_interface(&self, iface: glib::types::Type) -> Option<Element> {
343        unsafe {
344            from_glib_full(ffi::gst_bin_get_by_interface(
345                self.as_ref().to_glib_none().0,
346                iface.into_glib(),
347            ))
348        }
349    }
350
351    /// Gets the element with the given name from a bin. This
352    /// function recurses into child bins.
353    /// ## `name`
354    /// the element name to search for
355    ///
356    /// # Returns
357    ///
358    /// the [`Element`][crate::Element] with the given
359    /// name
360    #[doc(alias = "gst_bin_get_by_name")]
361    #[doc(alias = "get_by_name")]
362    fn by_name(&self, name: &str) -> Option<Element> {
363        unsafe {
364            from_glib_full(ffi::gst_bin_get_by_name(
365                self.as_ref().to_glib_none().0,
366                name.to_glib_none().0,
367            ))
368        }
369    }
370
371    /// Gets the element with the given name from this bin. If the
372    /// element is not found, a recursion is performed on the parent bin.
373    /// ## `name`
374    /// the element name to search for
375    ///
376    /// # Returns
377    ///
378    /// the [`Element`][crate::Element] with the given
379    /// name
380    #[doc(alias = "gst_bin_get_by_name_recurse_up")]
381    #[doc(alias = "get_by_name_recurse_up")]
382    fn by_name_recurse_up(&self, name: &str) -> Option<Element> {
383        unsafe {
384            from_glib_full(ffi::gst_bin_get_by_name_recurse_up(
385                self.as_ref().to_glib_none().0,
386                name.to_glib_none().0,
387            ))
388        }
389    }
390
391    ///
392    /// # Returns
393    ///
394    /// the bin's suppressed [`ElementFlags`][crate::ElementFlags].
395    #[doc(alias = "gst_bin_get_suppressed_flags")]
396    #[doc(alias = "get_suppressed_flags")]
397    fn suppressed_flags(&self) -> ElementFlags {
398        unsafe {
399            from_glib(ffi::gst_bin_get_suppressed_flags(
400                self.as_ref().to_glib_none().0,
401            ))
402        }
403    }
404
405    /// Queries `self` for the current latency and reconfigures this latency on all the
406    /// elements using a LATENCY event.
407    ///
408    /// This method is typically called on the pipeline when a `GST_MESSAGE_LATENCY`
409    /// is posted on the bus.
410    ///
411    /// This function simply emits the [`do-latency`][struct@crate::Bin#do-latency] signal so any custom latency
412    /// calculations will be performed.
413    ///
414    /// # Returns
415    ///
416    /// [`true`] if the latency could be queried and reconfigured.
417    #[doc(alias = "gst_bin_recalculate_latency")]
418    fn recalculate_latency(&self) -> Result<(), glib::error::BoolError> {
419        unsafe {
420            glib::result_from_gboolean!(
421                ffi::gst_bin_recalculate_latency(self.as_ref().to_glib_none().0),
422                "Failed to recalculate latency"
423            )
424        }
425    }
426
427    /// Removes the element from the bin, unparenting it as well.
428    /// Unparenting the element means that the element will be dereferenced,
429    /// so if the bin holds the only reference to the element, the element
430    /// will be freed in the process of removing it from the bin. If you
431    /// want the element to still exist after removing, you need to call
432    /// `gst_object_ref()` before removing it from the bin.
433    ///
434    /// If the element's pads are linked to other pads, the pads will be unlinked
435    /// before the element is removed from the bin.
436    /// ## `element`
437    /// the [`Element`][crate::Element] to remove
438    ///
439    /// # Returns
440    ///
441    /// [`true`] if the element could be removed, [`false`] if
442    /// the bin does not want to remove the element.
443    #[doc(alias = "gst_bin_remove")]
444    fn remove(&self, element: &impl IsA<Element>) -> Result<(), glib::error::BoolError> {
445        unsafe {
446            glib::result_from_gboolean!(
447                ffi::gst_bin_remove(
448                    self.as_ref().to_glib_none().0,
449                    element.as_ref().to_glib_none().0
450                ),
451                "Failed to remove element"
452            )
453        }
454    }
455
456    /// Suppresses the given flags on the bin. [`ElementFlags`][crate::ElementFlags] of a
457    /// child element are propagated when it is added to the bin.
458    /// When suppressed flags are set, those specified flags will
459    /// not be propagated to the bin.
460    /// ## `flags`
461    /// the [`ElementFlags`][crate::ElementFlags] to suppress
462    #[doc(alias = "gst_bin_set_suppressed_flags")]
463    fn set_suppressed_flags(&self, flags: ElementFlags) {
464        unsafe {
465            ffi::gst_bin_set_suppressed_flags(self.as_ref().to_glib_none().0, flags.into_glib());
466        }
467    }
468
469    /// Synchronizes the state of every child of `self` with the state
470    /// of `self`. See also [`ElementExt::sync_state_with_parent()`][crate::prelude::ElementExt::sync_state_with_parent()].
471    ///
472    /// # Returns
473    ///
474    /// [`true`] if syncing the state was successful for all children,
475    ///  otherwise [`false`].
476    #[doc(alias = "gst_bin_sync_children_states")]
477    fn sync_children_states(&self) -> Result<(), glib::error::BoolError> {
478        unsafe {
479            glib::result_from_gboolean!(
480                ffi::gst_bin_sync_children_states(self.as_ref().to_glib_none().0),
481                "Failed to sync children states"
482            )
483        }
484    }
485
486    /// If set to [`true`], the bin will handle asynchronous state changes.
487    /// This should be used only if the bin subclass is modifying the state
488    /// of its children on its own.
489    #[doc(alias = "async-handling")]
490    fn is_async_handling(&self) -> bool {
491        ObjectExt::property(self.as_ref(), "async-handling")
492    }
493
494    /// If set to [`true`], the bin will handle asynchronous state changes.
495    /// This should be used only if the bin subclass is modifying the state
496    /// of its children on its own.
497    #[doc(alias = "async-handling")]
498    fn set_async_handling(&self, async_handling: bool) {
499        ObjectExt::set_property(self.as_ref(), "async-handling", async_handling)
500    }
501
502    /// Forward all children messages, even those that would normally be filtered by
503    /// the bin. This can be interesting when one wants to be notified of the EOS
504    /// state of individual elements, for example.
505    ///
506    /// The messages are converted to an ELEMENT message with the bin as the
507    /// source. The structure of the message is named `GstBinForwarded` and contains
508    /// a field named `message` that contains the original forwarded [`Message`][crate::Message].
509    #[doc(alias = "message-forward")]
510    fn is_message_forward(&self) -> bool {
511        ObjectExt::property(self.as_ref(), "message-forward")
512    }
513
514    /// Forward all children messages, even those that would normally be filtered by
515    /// the bin. This can be interesting when one wants to be notified of the EOS
516    /// state of individual elements, for example.
517    ///
518    /// The messages are converted to an ELEMENT message with the bin as the
519    /// source. The structure of the message is named `GstBinForwarded` and contains
520    /// a field named `message` that contains the original forwarded [`Message`][crate::Message].
521    #[doc(alias = "message-forward")]
522    fn set_message_forward(&self, message_forward: bool) {
523        ObjectExt::set_property(self.as_ref(), "message-forward", message_forward)
524    }
525
526    /// Will be emitted after the element was added to `sub_bin`.
527    /// ## `sub_bin`
528    /// the [`Bin`][crate::Bin] the element was added to
529    /// ## `element`
530    /// the [`Element`][crate::Element] that was added to `sub_bin`
531    #[doc(alias = "deep-element-added")]
532    fn connect_deep_element_added<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(
533        &self,
534        f: F,
535    ) -> SignalHandlerId {
536        unsafe extern "C" fn deep_element_added_trampoline<
537            P: IsA<Bin>,
538            F: Fn(&P, &Bin, &Element) + Send + Sync + 'static,
539        >(
540            this: *mut ffi::GstBin,
541            sub_bin: *mut ffi::GstBin,
542            element: *mut ffi::GstElement,
543            f: glib::ffi::gpointer,
544        ) {
545            unsafe {
546                let f: &F = &*(f as *const F);
547                f(
548                    Bin::from_glib_borrow(this).unsafe_cast_ref(),
549                    &from_glib_borrow(sub_bin),
550                    &from_glib_borrow(element),
551                )
552            }
553        }
554        unsafe {
555            let f: Box_<F> = Box_::new(f);
556            connect_raw(
557                self.as_ptr() as *mut _,
558                c"deep-element-added".as_ptr(),
559                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
560                    deep_element_added_trampoline::<Self, F> as *const (),
561                )),
562                Box_::into_raw(f),
563            )
564        }
565    }
566
567    /// Will be emitted after the element was removed from `sub_bin`.
568    /// ## `sub_bin`
569    /// the [`Bin`][crate::Bin] the element was removed from
570    /// ## `element`
571    /// the [`Element`][crate::Element] that was removed from `sub_bin`
572    #[doc(alias = "deep-element-removed")]
573    fn connect_deep_element_removed<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(
574        &self,
575        f: F,
576    ) -> SignalHandlerId {
577        unsafe extern "C" fn deep_element_removed_trampoline<
578            P: IsA<Bin>,
579            F: Fn(&P, &Bin, &Element) + Send + Sync + 'static,
580        >(
581            this: *mut ffi::GstBin,
582            sub_bin: *mut ffi::GstBin,
583            element: *mut ffi::GstElement,
584            f: glib::ffi::gpointer,
585        ) {
586            unsafe {
587                let f: &F = &*(f as *const F);
588                f(
589                    Bin::from_glib_borrow(this).unsafe_cast_ref(),
590                    &from_glib_borrow(sub_bin),
591                    &from_glib_borrow(element),
592                )
593            }
594        }
595        unsafe {
596            let f: Box_<F> = Box_::new(f);
597            connect_raw(
598                self.as_ptr() as *mut _,
599                c"deep-element-removed".as_ptr(),
600                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
601                    deep_element_removed_trampoline::<Self, F> as *const (),
602                )),
603                Box_::into_raw(f),
604            )
605        }
606    }
607
608    /// Will be emitted after the element was added to the bin.
609    /// ## `element`
610    /// the [`Element`][crate::Element] that was added to the bin
611    #[doc(alias = "element-added")]
612    fn connect_element_added<F: Fn(&Self, &Element) + Send + Sync + 'static>(
613        &self,
614        f: F,
615    ) -> SignalHandlerId {
616        unsafe extern "C" fn element_added_trampoline<
617            P: IsA<Bin>,
618            F: Fn(&P, &Element) + Send + Sync + 'static,
619        >(
620            this: *mut ffi::GstBin,
621            element: *mut ffi::GstElement,
622            f: glib::ffi::gpointer,
623        ) {
624            unsafe {
625                let f: &F = &*(f as *const F);
626                f(
627                    Bin::from_glib_borrow(this).unsafe_cast_ref(),
628                    &from_glib_borrow(element),
629                )
630            }
631        }
632        unsafe {
633            let f: Box_<F> = Box_::new(f);
634            connect_raw(
635                self.as_ptr() as *mut _,
636                c"element-added".as_ptr(),
637                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
638                    element_added_trampoline::<Self, F> as *const (),
639                )),
640                Box_::into_raw(f),
641            )
642        }
643    }
644
645    /// Will be emitted after the element was removed from the bin.
646    /// ## `element`
647    /// the [`Element`][crate::Element] that was removed from the bin
648    #[doc(alias = "element-removed")]
649    fn connect_element_removed<F: Fn(&Self, &Element) + Send + Sync + 'static>(
650        &self,
651        f: F,
652    ) -> SignalHandlerId {
653        unsafe extern "C" fn element_removed_trampoline<
654            P: IsA<Bin>,
655            F: Fn(&P, &Element) + Send + Sync + 'static,
656        >(
657            this: *mut ffi::GstBin,
658            element: *mut ffi::GstElement,
659            f: glib::ffi::gpointer,
660        ) {
661            unsafe {
662                let f: &F = &*(f as *const F);
663                f(
664                    Bin::from_glib_borrow(this).unsafe_cast_ref(),
665                    &from_glib_borrow(element),
666                )
667            }
668        }
669        unsafe {
670            let f: Box_<F> = Box_::new(f);
671            connect_raw(
672                self.as_ptr() as *mut _,
673                c"element-removed".as_ptr(),
674                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
675                    element_removed_trampoline::<Self, F> as *const (),
676                )),
677                Box_::into_raw(f),
678            )
679        }
680    }
681
682    #[doc(alias = "async-handling")]
683    fn connect_async_handling_notify<F: Fn(&Self) + Send + Sync + 'static>(
684        &self,
685        f: F,
686    ) -> SignalHandlerId {
687        unsafe extern "C" fn notify_async_handling_trampoline<
688            P: IsA<Bin>,
689            F: Fn(&P) + Send + Sync + 'static,
690        >(
691            this: *mut ffi::GstBin,
692            _param_spec: glib::ffi::gpointer,
693            f: glib::ffi::gpointer,
694        ) {
695            unsafe {
696                let f: &F = &*(f as *const F);
697                f(Bin::from_glib_borrow(this).unsafe_cast_ref())
698            }
699        }
700        unsafe {
701            let f: Box_<F> = Box_::new(f);
702            connect_raw(
703                self.as_ptr() as *mut _,
704                c"notify::async-handling".as_ptr(),
705                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
706                    notify_async_handling_trampoline::<Self, F> as *const (),
707                )),
708                Box_::into_raw(f),
709            )
710        }
711    }
712
713    #[doc(alias = "message-forward")]
714    fn connect_message_forward_notify<F: Fn(&Self) + Send + Sync + 'static>(
715        &self,
716        f: F,
717    ) -> SignalHandlerId {
718        unsafe extern "C" fn notify_message_forward_trampoline<
719            P: IsA<Bin>,
720            F: Fn(&P) + Send + Sync + 'static,
721        >(
722            this: *mut ffi::GstBin,
723            _param_spec: glib::ffi::gpointer,
724            f: glib::ffi::gpointer,
725        ) {
726            unsafe {
727                let f: &F = &*(f as *const F);
728                f(Bin::from_glib_borrow(this).unsafe_cast_ref())
729            }
730        }
731        unsafe {
732            let f: Box_<F> = Box_::new(f);
733            connect_raw(
734                self.as_ptr() as *mut _,
735                c"notify::message-forward".as_ptr(),
736                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
737                    notify_message_forward_trampoline::<Self, F> as *const (),
738                )),
739                Box_::into_raw(f),
740            )
741        }
742    }
743}
744
745impl<O: IsA<Bin>> GstBinExt for O {}